# Searching the term using Facet Query

**URL:** <https://discuss.elastic.co/t/searching-the-term-using-facet-query/7459>\
**Category:** Elasticsearch\
**Created:** [April 25, 2012, 6:55am UTC](https://discuss.elastic.co/t/searching-the-term-using-facet-query/7459 "2012-04-25T06:55:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sumit\_Guptaa](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@Sumit\_Guptaa](https://discuss.elastic.co/u/Sumit_Guptaa)\
**Post date:** [April 25, 2012, 6:55am UTC](https://discuss.elastic.co/t/searching-the-term-using-facet-query/7459/1 "2012-04-25T06:55:43Z")

</div>

hi all,

i m creating index like....

curl -XPOST '[http://localhost:9200/foo/bar?pretty=1](http://localhost:9200/foo/bar?pretty=1)' -d '  
{  
"text" : [  
"abc xyz abc def abc xyz",  
"abc xyz abc"  
]  
}  
'

and when i am searching for "abc" then i want count like "abc" : "5","xyz" : "3" ,"def" :"1"  
and when i m searching for "abc xyz" then i want count like "abc xyz" : "3","abc" : "2","def" : "1"  
and when i m searching for "abc xyz abc" then i want count like "abc xyz abc" : "2","abc" : "1","xyz" : "1","abc" : "1"

please help me as soon as possible..

Rgds,  
Sumit Gupta

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 27, 2012, 8:59am UTC](https://discuss.elastic.co/t/searching-the-term-using-facet-query/7459/2 "2012-04-27T08:59:35Z")

</div>

You could potentially use query facets, and have a query yourself broken  
down based on the provided text, you can have several query facet (a query  
facet is a simple one that returns count for hte docs matching the query).

On Wed, Apr 25, 2012 at 9:55 AM, Sumit Guptaa [sumit.gupta.ngi@gmail.com](mailto:sumit.gupta.ngi@gmail.com)wrote:

> hi all,
> 
> i m creating index like....
> 
> curl -XPOST '[http://localhost:9200/foo/bar?pretty=1](http://localhost:9200/foo/bar?pretty=1)' -d '  
> {  
> "text" : [  
> "abc xyz abc def abc xyz",  
> "abc xyz abc"  
> ]  
> }  
> '
> 
> and when i am searching for "abc" then i want count like "abc" : "5","xyz"  
> :  
> "3" ,"def" :"1"  
> and when i m searching for "abc xyz" then i want count like "abc xyz" :  
> "3","abc" : "2","def" : "1"  
> and when i m searching for "abc xyz abc" then i want count like "abc xyz  
> abc" : "2","abc" : "1","xyz" : "1","abc" : "1"
> 
> please help me as soon as possible..
> 
> Rgds,  
> Sumit Gupta
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Searching-the-term-using-Facet-Query-tp3937476p3937476.html](http://elasticsearch-users.115913.n3.nabble.com/Searching-the-term-using-Facet-Query-tp3937476p3937476.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Sumit\_Guptaa](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@Sumit\_Guptaa](https://discuss.elastic.co/u/Sumit_Guptaa)\
**Post date:** [April 27, 2012, 11:32am UTC](https://discuss.elastic.co/t/searching-the-term-using-facet-query/7459/3 "2012-04-27T11:32:09Z")

</div>

hi  
thanx shay

sir please give me example for this implementation....it would be good for me...

Regards,  
Sumit Gupta

---

<div class="post-metadata">

**Author:** ![pulkitsinghal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pulkitsinghal/32/802_2.png) [@pulkitsinghal](https://discuss.elastic.co/u/pulkitsinghal)\
**Post date:** [May 28, 2012, 1:04pm UTC](https://discuss.elastic.co/t/searching-the-term-using-facet-query/7459/4 "2012-05-28T13:04:08Z")

</div>

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Fri, Apr 27, 2012 at 6:32 AM, Sumit Guptaa [sumit.gupta.ngi@gmail.com](mailto:sumit.gupta.ngi@gmail.com)wrote:

> hi  
> thanx shay
> 
> sir please give me example for this implementation....it would be good for  
> me...
> 
> Regards,  
> Sumit Gupta
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Searching-the-term-using-Facet-Query-tp3937476p3944057.html](http://elasticsearch-users.115913.n3.nabble.com/Searching-the-term-using-Facet-Query-tp3937476p3944057.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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, 3:26am UTC](https://discuss.elastic.co/t/searching-the-term-using-facet-query/7459/5 "2017-07-06T03:26:40Z")

</div>


