Reference Entry
RangeQuery Over Lexical Fields
Lexical Querying · querying · order 40
Filter sortable string terms with gt, gte, lt, and lte boundaries through the JSON DSL.
Relevant APIs
RangeQuery Over Lexical Fields
range compares string terms lexically. That works best when values are already sortable as strings.
Example
{
"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" } })]
});
Practical note
If you want numeric-style ordering, store values as zero-padded strings such as 01, 02, and 10.