# Elastic search : Facet Query

**URL:** <https://discuss.elastic.co/t/elastic-search-facet-query/11308>\
**Category:** Elasticsearch\
**Created:** [March 26, 2013, 6:17am UTC](https://discuss.elastic.co/t/elastic-search-facet-query/11308 "2013-03-26T06:17:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohit\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@mohit\_Kumar](https://discuss.elastic.co/u/mohit_Kumar)\
**Post date:** [March 26, 2013, 6:17am UTC](https://discuss.elastic.co/t/elastic-search-facet-query/11308/1 "2013-03-26T06:17:21Z")

</div>

HI Floks,

Below is my Elastic search query with facets and its result.

I have a field in elastic search "TopicWords":"[http://t.co/uky](http://t.co/uky)". And i am  
running the facet query in it.

My ESquery:-  
curl -XGET '[http://localhost:9200/new\_index/new\_indext/\_search?size=0](http://localhost:9200/new_index/new_indext/_search?size=0)'  
-d'{"query":{"filtered":{"query":{"bool":{"should":[{"field":{"TopicWords":"  
[http://t.co/uky"}},"minimum\_number\_should\_match](http://t.co/uky%22%7D%7D,%22minimum_number_should_match)":1}}, "filter":  
{"range":{"CreatedAt":  
{"from":"2013-02-01T00:00:00"}}}}},"facets":{"TopicWords":{"terms":{"field":"TopicWords","size":200}}}}'

results:  
{"took":134,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max\_score":0.23350935,"hits":[{"\_index":"new\_index","\_type":"new\_indext","\_id":"314658172369518592","\_score":0.23350935,"fields":{"\_id":"314658172369518592"}}]},"facets":{"TopicWords":{"\_type":"terms","missing":0,"total":11,"other":1,"terms":[{"term":"uky","count":1},{"term":"  
[t.co](http://t.co)","count":1},{"term":"http","count":1}]}}}

I am pretty confuse why facet result is coming like this. It splits on : ,  
// and / i.e. "terms":[{"term":"uky","count":1},{"term":"[t.co](http://t.co)  
","count":1},{"term":"http","count":1}]

How i get the exact value of the Topicwords Field in return of facet query  
without splitting.

Regrads  
Mohit Kumar Yadav  
(MCA/BBA)  
Email Id : [mohit.kumar.ngi@gmail.com](mailto:mohit.kumar.ngi@gmail.com)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [March 26, 2013, 6:59am UTC](https://discuss.elastic.co/t/elastic-search-facet-query/11308/2 "2013-03-26T06:59:10Z")

</div>

You have to change your mapping and set your field to not analyzed or use a keyword analyzer.  
If you need also to search on this field, you can use multifield type and define a mapping for search (default) and one other for facets (TopicWords.facet for example)

## HTH

David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 26 mars 2013 à 07:17, Mohit Kumar Yadav [mohit.kumar.ngi@gmail.com](mailto:mohit.kumar.ngi@gmail.com) a écrit :

HI Floks,

Below is my Elastic search query with facets and its result.

I have a field in elastic search "TopicWords":"[http://t.co/uky](http://t.co/uky)". And i am running the facet query in it.

My ESquery:-  
curl -XGET '[http://localhost:9200/new\_index/new\_indext/\_search?size=0](http://localhost:9200/new_index/new_indext/_search?size=0)' -d'{"query":{"filtered":{"query":{"bool":{"should":[{"field":{"TopicWords":"[http://t.co/uky"}},"minimum\_number\_should\_match](http://t.co/uky%22%7D%7D,%22minimum_number_should_match)":1}}, "filter": {"range":{"CreatedAt": {"from":"2013-02-01T00:00:00"}}}}},"facets":{"TopicWords":{"terms":{"field":"TopicWords","size":200}}}}'

results:  
{"took":134,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max\_score":0.23350935,"hits":[{"\_index":"new\_index","\_type":"new\_indext","\_id":"314658172369518592","\_score":0.23350935,"fields":{"\_id":"314658172369518592"}}]},"facets":{"TopicWords":{"\_type":"terms","missing":0,"total":11,"other":1,"terms":[{"term":"uky","count":1},{"term":"t.co","count":1},{"term":"http","count":1}]}}}

I am pretty confuse why facet result is coming like this. It splits on : , // and / i.e. "terms":[{"term":"uky","count":1},{"term":"t.co","count":1},{"term":"http","count":1}]

How i get the exact value of the Topicwords Field in return of facet query without splitting.

## Regrads Mohit Kumar Yadav (MCA/BBA) Email Id : [mohit.kumar.ngi@gmail.com](mailto:mohit.kumar.ngi@gmail.com)

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:44am UTC](https://discuss.elastic.co/t/elastic-search-facet-query/11308/3 "2017-07-06T02:44:28Z")

</div>


