Skip to content

Numeric Filters

NumericFilterInput filters on numeric or date fields. Use it inside a ComplexFilterInput to express range queries, exact matches, and null checks on quantities, totals, timestamps, and other numeric data.


Type Definition

graphql
input FilterConditionInput {
  property: String!    # The Elasticsearch field name
  operator: String!    # lt | gt | lte | gte | eq | is_null | is_not_null
  value: Float         # The comparison value (not required for is_null / is_not_null)
}

Numeric conditions are inline within FilterConditionInput — set property, operator, and value directly.

For date fields, pass the value as a Unix timestamp in milliseconds (e.g. 1704067200000 for 2024-01-01T00:00:00Z).


Operators

OperatorDescriptionExample
ltLess thantotal < 100
gtGreater thantotal > 50
lteLess than or equaltotal <= 100
gteGreater than or equaltotal >= 50
eqExactly equaltotal = 59.98
is_nullField is absent / nullcompletedAt is null
is_not_nullField is present / not nullcompletedAt is not null

Examples

Orders with total greater than 100

graphql
complexFilters: {
  must: [
    { property: "total", operator: gt, value: 100 }
  ]
}

Orders placed in a date range

Dates are provided as Unix timestamps in milliseconds:

graphql
complexFilters: {
  must: [
    { property: "issuedAt", operator: gte, value: 1704067200000 },  # 2024-01-01
    { property: "issuedAt", operator: lte, value: 1735689599000 }   # 2024-12-31
  ]
}

Orders not yet completed

graphql
complexFilters: {
  must: [
    { property: "completedAt", operator: is_null }
  ]
}

Orders that have been completed

graphql
complexFilters: {
  must: [
    { property: "completedAt", operator: is_not_null }
  ]
}

Stock references with zero available quantity

graphql
complexFilters: {
  must: [
    { property: "availableQuantity", operator: eq, value: 0 }
  ]
}

Stock references with no quantity record (is_null)

graphql
complexFilters: {
  must: [
    { property: "availableQuantity", operator: is_null }
  ]
}

Combining numeric and facet filters

Orders that are OPENED with a total between 50 and 500:

graphql
complexFilters: {
  must: [
    { property: "organizationId", operator: in, values: ["org-abc123"] },
    { property: "state", operator: in, values: ["OPENED"] },
    { property: "total", operator: gte, value: 50 },
    { property: "total", operator: lte, value: 500 }
  ]
}

Full Example — Orders in a Date Range with Minimum Total

bash
curl -X POST https://api-v3.happycolis.com/graphql \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query SearchOrders($input: SearchInput!) { orderRecords(input: $input) { hits { objectID invoiceNumber total issuedAt } nbHits } }",
    "variables": {
      "input": {
        "complexFilters": {
          "must": [
            { "property": "organizationId", "operator": "in", "values": ["org-abc123"] },
            { "property": "issuedAt", "operator": "gte", "value": 1704067200000 },
            { "property": "issuedAt", "operator": "lte", "value": 1735689599000 },
            { "property": "total", "operator": "gt", "value": 100 }
          ]
        },
        "sort": [{ "property": "issuedAt", "order": "desc" }],
        "hitsPerPage": 50,
        "page": 0
      }
    }
  }'
javascript
const response = await fetch('https://api-v3.happycolis.com/graphql', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${ACCESS_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    query: `query SearchOrders($input: SearchInput!) {
      orderRecords(input: $input) {
        hits { objectID invoiceNumber total issuedAt }
        nbHits
      }
    }`,
    variables: {
      input: {
        complexFilters: {
          must: [
            { property: 'organizationId', operator: 'in', values: ['org-abc123'] },
            { property: 'issuedAt', operator: 'gte', value: 1704067200000 },
            { property: 'issuedAt', operator: 'lte', value: 1735689599000 },
            { property: 'total', operator: 'gt', value: 100 },
          ],
        },
        sort: [{ property: 'issuedAt', order: 'desc' }],
        hitsPerPage: 50,
        page: 0,
      },
    },
  }),
});
const { data } = await response.json();
python
import requests

response = requests.post(
    'https://api-v3.happycolis.com/graphql',
    headers={
        'Authorization': f'Bearer {ACCESS_TOKEN}',
        'Content-Type': 'application/json',
    },
    json={
        'query': '''
            query SearchOrders($input: SearchInput!) {
                orderRecords(input: $input) {
                    hits { objectID invoiceNumber total issuedAt }
                    nbHits
                }
            }
        ''',
        'variables': {
            'input': {
                'complexFilters': {
                    'must': [
                        {'property': 'organizationId', 'operator': 'in', 'values': ['org-abc123']},
                        {'property': 'issuedAt', 'operator': 'gte', 'value': 1704067200000},
                        {'property': 'issuedAt', 'operator': 'lte', 'value': 1735689599000},
                        {'property': 'total', 'operator': 'gt', 'value': 100},
                    ],
                },
                'sort': [{'property': 'issuedAt', 'order': 'desc'}],
                'hitsPerPage': 50,
                'page': 0,
            }
        },
    }
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api-v3.happycolis.com/graphql', [
    'headers' => [
        'Authorization' => 'Bearer ' . $ACCESS_TOKEN,
        'Content-Type'  => 'application/json',
    ],
    'json' => [
        'query' => 'query SearchOrders($input: SearchInput!) {
            orderRecords(input: $input) {
                hits { objectID invoiceNumber total issuedAt }
                nbHits
            }
        }',
        'variables' => [
            'input' => [
                'complexFilters' => [
                    'must' => [
                        ['property' => 'organizationId', 'operator' => 'in', 'values' => ['org-abc123']],
                        ['property' => 'issuedAt', 'operator' => 'gte', 'value' => 1704067200000],
                        ['property' => 'issuedAt', 'operator' => 'lte', 'value' => 1735689599000],
                        ['property' => 'total', 'operator' => 'gt', 'value' => 100],
                    ],
                ],
                'sort' => [['property' => 'issuedAt', 'order' => 'desc']],
                'hitsPerPage' => 50,
                'page' => 0,
            ],
        ],
    ],
]);
$data = json_decode($response->getBody(), true);
go
package main

import (
    "bytes"
    "encoding/json"
    "net/http"
)

payload, _ := json.Marshal(map[string]interface{}{
    "query": `query SearchOrders($input: SearchInput!) {
        orderRecords(input: $input) {
            hits { objectID invoiceNumber total issuedAt }
            nbHits
        }
    }`,
    "variables": map[string]interface{}{
        "input": map[string]interface{}{
            "complexFilters": map[string]interface{}{
                "must": []map[string]interface{}{
                    {"property": "organizationId", "operator": "in", "values": []string{"org-abc123"}},
                    {"property": "issuedAt", "operator": "gte", "value": 1704067200000},
                    {"property": "issuedAt", "operator": "lte", "value": 1735689599000},
                    {"property": "total", "operator": "gt", "value": 100},
                },
            },
            "sort": []map[string]interface{}{
                {"property": "issuedAt", "order": "desc"},
            },
            "hitsPerPage": 50,
            "page":        0,
        },
    },
})
req, _ := http.NewRequest("POST", "https://api-v3.happycolis.com/graphql", bytes.NewBuffer(payload))
req.Header.Set("Authorization", "Bearer "+ACCESS_TOKEN)
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)

Date Field Reference

Date fields in the index store values as Unix timestamps in milliseconds. Use an online converter or compute them in code:

javascript
// JavaScript — start of 2024-01-01 UTC
const startOf2024 = new Date('2024-01-01T00:00:00Z').getTime(); // 1704067200000

// JavaScript — end of 2024-12-31 UTC
const endOf2024 = new Date('2024-12-31T23:59:59Z').getTime();   // 1735689599000
python
# Python
from datetime import datetime, timezone
start = int(datetime(2024, 1, 1, tzinfo=timezone.utc).timestamp() * 1000)  # 1704067200000
end   = int(datetime(2024, 12, 31, 23, 59, 59, tzinfo=timezone.utc).timestamp() * 1000)

Common date fields:

DomainFieldDescription
OrdersissuedAtWhen the order was placed
OrderscompletedAtWhen the order reached terminal state
OrderscreatedAtWhen the order record was created
ShipmentsshippedAtWhen the shipment was dispatched
ShipmentsdeliveredAtWhen the shipment was delivered
Delivery OrdersacceptedAtWhen the delivery order was accepted

HappyColis API Documentation