# Index integer type took more time to search, confused

**URL:** <https://discuss.elastic.co/t/index-integer-type-took-more-time-to-search-confused/168363>\
**Category:** Elasticsearch\
**Created:** [February 14, 2019, 9:01am UTC](https://discuss.elastic.co/t/index-integer-type-took-more-time-to-search-confused/168363 "2019-02-14T09:01:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yaoqijun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaoqijun/32/32028_2.png) [@yaoqijun](https://discuss.elastic.co/u/yaoqijun)\
**Post date:** [February 14, 2019, 9:01am UTC](https://discuss.elastic.co/t/index-integer-type-took-more-time-to-search-confused/168363/1 "2019-02-14T09:01:10Z")

</div>

this is my index mapping ,  
{  
"myIndex":{  
"mappings":{  
"discovery":{  
"properties":{  
"create\_time":{  
"type":"long",  
"index":false  
},  
"delete\_tag":{  
"type":"integer"  
},  
"desc":{  
"type":"text",  
"analyzer":"ik\_smart"  
},  
"desc\_summary":{  
"type":"text",  
"analyzer":"ik\_smart"  
},  
"hot\_huati\_good\_ids":{  
"type":"keyword"  
},  
"hot\_huati\_top\_ids":{  
"type":"keyword"  
},  
"name":{  
"type":"text",  
"analyzer":"ik\_smart"  
},  
"page\_id\_list":{  
"type":"keyword"  
},  
"is\_qualified": {  
"type": "integer"  
}  
}  
}  
}  
}  
}

it has is\_qualified field. has been indexed,  
so i search json is  
{  
"from":0,  
"size":20,  
"query":{  
"bool":{  
"filter":[  
{  
"bool":{  
"should":[  
{  
"term":{  
"page\_id\_list":{  
"value":"5a4384878000862471d147fc",  
"boost":1  
}  
}  
},  
{  
"term":{  
"hot\_huati\_top\_ids":{  
"value":"5a4384878000862471d147fc",  
"boost":1  
}  
}  
},  
{  
"term":{  
"hot\_huati\_good\_ids":{  
"value":"5a4384878000862471d147fc",  
"boost":1  
}  
}  
}  
],  
"adjust\_pure\_negative":true,  
"boost":1  
}  
},  
{  
"term":{  
"delete\_tag":{  
"value":1,  
"boost":1  
}  
}  
}  
],  
"should":[  
{  
"match":{  
"name":{  
"query":"兰蔻",  
"boost":20  
}  
}  
},  
{  
"match":{  
"desc\_summary":{  
"query":"兰蔻",  
"boost":10  
}  
}  
},  
{  
"term":{  
"is\_qualified":{  
"value":1,  
"boost":40  
}  
}  
}  
],  
"adjust\_pure\_negative":true,  
"boost":1  
}  
},  
"\_source": false  
}

![image](https://us1.discourse-cdn.com/elastic/original/3X/3/6/36f7bb9c083a4af8030d7c5222f345e1afbeadfd.png)

it toke 342ms , remove is\_qualified boost but if ichange search json with  
{  
"from":0,  
"size":20,  
"query":{  
"bool":{  
"filter":[  
{  
"bool":{  
"should":[  
{  
"term":{  
"page\_id\_list":{  
"value":"5a4384878000862471d147fc",  
"boost":1  
}  
}  
},  
{  
"term":{  
"hot\_huati\_top\_ids":{  
"value":"5a4384878000862471d147fc",  
"boost":1  
}  
}  
},  
{  
"term":{  
"hot\_huati\_good\_ids":{  
"value":"5a4384878000862471d147fc",  
"boost":1  
}  
}  
}  
],  
"adjust\_pure\_negative":true,  
"boost":1  
}  
},  
{  
"term":{  
"delete\_tag":{  
"value":1,  
"boost":1  
}  
}  
}  
],  
"should":[  
{  
"match":{  
"name":{  
"query":"兰蔻",  
"boost":20  
}  
}  
},  
{  
"match":{  
"desc\_summary":{  
"query":"兰蔻",  
"boost":10  
}  
}  
}  
],  
"adjust\_pure\_negative":true,  
"boost":1  
}  
},  
"\_source": false  
}

![image](https://us1.discourse-cdn.com/elastic/original/3X/0/2/02ba48f7e3f114fbbe04114cc8586d7103134300.png)

took time save a lot , so the reason is ? should i change the is\_qualified filed type to keyword??

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [February 18, 2019, 10:25am UTC](https://discuss.elastic.co/t/index-integer-type-took-more-time-to-search-confused/168363/2 "2019-02-18T10:25:39Z")

</div>

Numeric datatypes are optimised for range searches (give me everything between 'a' and 'b') and they are not the fastest when performing term queries.

I would change is\_qualified to a boolean datatype if possible, else you should use keyword data type.

---

<div class="post-metadata">

**Author:** ![yaoqijun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaoqijun/32/32028_2.png) [@yaoqijun](https://discuss.elastic.co/u/yaoqijun)\
**Post date:** [February 18, 2019, 10:37am UTC](https://discuss.elastic.co/t/index-integer-type-took-more-time-to-search-confused/168363/3 "2019-02-18T10:37:12Z")

</div>

i try, improve a lot, thks

---

<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:** [March 18, 2019, 10:37am UTC](https://discuss.elastic.co/t/index-integer-type-took-more-time-to-search-confused/168363/4 "2019-03-18T10:37:15Z")

</div>

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