How to select records with "-" ina text field( price ) in elastic search

Sample records need to be selected

{
"_index" : "sample",
"_type" : "_doc",
"_id" : "1213",
"_version" : 2,
"_seq_no" : 2227876,
"_primary_term" : 1,
"found" : true,
"_source" : {
"id" : 1213,
"price" : "-7284869.0",
"updatedDate" : "2019-06-26T12:40:16.6197147-05:00"
}
}

Not working
GET sample/_search
{
"query": {
"bool": {
"must": [
{
"prefix": {
"price": "-"
}
}
]
}
}
}

It depends on the mapping used for this field. With a keyword type it should work.

1 Like

Is there is any other way to filter(with - ) the records ,if the mapping of the field(price) is text

I don't think so as - has probably be removed at index time.
Check the analyzer API to see how your text has been indexed behind the scene.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.