| id | range-filters | |||||
|---|---|---|---|---|---|---|
| section | Lexical Querying | |||||
| title | RangeQuery Over Lexical Fields | |||||
| summary | Filter sortable string terms with gt, gte, lt, and lte boundaries through the JSON DSL. | |||||
| tags |
|
|||||
| apis |
|
|||||
| level | querying | |||||
| order | 40 |
range compares string terms lexically. That works best when values are already sortable as strings.
{
"query": {
"bool": {
"filter": [
{
"range": {
"order": {
"gte": "03",
"lte": "07"
}
}
}
]
}
}
}Equivalent internal TypeScript API:
import { BoolQuery, RangeQuery } from "@tryformation/querylight-ts";
const query = new BoolQuery({
filter: [new RangeQuery({ field: "order", range: { gte: "03", lte: "07" } })]
});If you want numeric-style ordering, store values as zero-padded strings such as 01, 02, and 10.