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

**URL:** <https://discuss.elastic.co/t/how-to-select-records-with-ina-text-field-price-in-elastic-search/188007>\
**Category:** Elasticsearch\
**Created:** [June 28, 2019, 9:37am UTC](https://discuss.elastic.co/t/how-to-select-records-with-ina-text-field-price-in-elastic-search/188007 "2019-06-28T09:37:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SudevPK](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@SudevPK](https://discuss.elastic.co/u/SudevPK)\
**Post date:** [June 28, 2019, 9:37am UTC](https://discuss.elastic.co/t/how-to-select-records-with-ina-text-field-price-in-elastic-search/188007/1 "2019-06-28T09:37:49Z")

</div>

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"  
}  
}

---

<div class="post-metadata">

**Author:** ![SudevPK](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@SudevPK](https://discuss.elastic.co/u/SudevPK)\
**Post date:** [June 28, 2019, 9:44am UTC](https://discuss.elastic.co/t/how-to-select-records-with-ina-text-field-price-in-elastic-search/188007/2 "2019-06-28T09:44:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 28, 2019, 9:56am UTC](https://discuss.elastic.co/t/how-to-select-records-with-ina-text-field-price-in-elastic-search/188007/3 "2019-06-28T09:56:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![SudevPK](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@SudevPK](https://discuss.elastic.co/u/SudevPK)\
**Post date:** [July 1, 2019, 6:43am UTC](https://discuss.elastic.co/t/how-to-select-records-with-ina-text-field-price-in-elastic-search/188007/4 "2019-07-01T06:43:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 1, 2019, 8:16am UTC](https://discuss.elastic.co/t/how-to-select-records-with-ina-text-field-price-in-elastic-search/188007/5 "2019-07-01T08:16:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 29, 2019, 8:18am UTC](https://discuss.elastic.co/t/how-to-select-records-with-ina-text-field-price-in-elastic-search/188007/6 "2019-07-29T08:18:04Z")

</div>

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