lucene - Search for a numeric range inside string in elastic search -
i wanted search numeric expression in elastic search.
example
indent code 4.8663 spaces indent code 121.232 spaces indent code 12.3232 spaces
example query
get string "indent code between 1 , 100"
it should 1st , 3rd not 2nd.
{ "span_near": { "in_order": 1, "clauses": [ { "span_term": { "request": "indent" } }, { "span_term": { "request": "code" } } , { "span_multi": { "match":{ "range": { "request": { "to": 100, "from": 1 } } } } } ], "slop": 0, "collect_payloads": 0 } }
giving wrong result. comparing using termrangequery rather numericrangequery.
if can either replace float numbers integer numbers (4.8663 => 5) or multiply float numbers chosen power of 10 numbers become integers (4.8663 => 48663), might able use regexp
query this.
i've indexed 3 documents integer numbers (5, 121 , 12) , i've been able retrieve 2 in 1-100 interval using following query.
{ "query": { "regexp": { "request": { "value": "<1-100>" } } } }
if absolutely need keep precision other reasons, might not work out you.
Comments
Post a Comment