# Help needed for faceting query

**URL:** <https://discuss.elastic.co/t/help-needed-for-faceting-query/11557>\
**Category:** Elasticsearch\
**Created:** [April 12, 2013, 4:28am UTC](https://discuss.elastic.co/t/help-needed-for-faceting-query/11557 "2013-04-12T04:28:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_Andhavarapu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhishek_andhavarapu/32/782_2.png) [@Abhishek\_Andhavarapu](https://discuss.elastic.co/u/Abhishek_Andhavarapu)\
**Post date:** [April 12, 2013, 4:28am UTC](https://discuss.elastic.co/t/help-needed-for-faceting-query/11557/1 "2013-04-12T04:28:03Z")

</div>

Hello all,

I wondering if I can write a faceting query for something like this

My document structure

UserID, AnswerID[] (int array)  
1 , [9,10,11,56,78,99]  
2 , [10,11,56,78,99]  
3 , [8,10,12,56, 79,99]  
4 , [9,10,11,56,78,99]

If want the count of users who answered 9,56 I can write a query. But I  
have two lists

List A - 9,10,11  
ListB - 56,78,99

I want the permutation of the two lists.

Count of users who answered [9,56], [9,78], [9,99], [10,56], [10,78],  
[10,99], [11,56]...

How do I write a query to achieve something like this.

Any help is appreciated,

Thanks.

--  
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:** [April 12, 2013, 7:04am UTC](https://discuss.elastic.co/t/help-needed-for-faceting-query/11557/2 "2013-04-12T07:04:40Z")

</div>

On single value fields, it could work using a script\_field: [Test TermsFacet with script\_field: http://stackoverflow.com/questions/15963088/elasticsearch-faceting-query · GitHub](https://gist.github.com/dadoonet/5370077)  
I did not find a way to do it on lists. May be Igor or someone else has an idea???

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 12 avr. 2013 à 06:28, Abhishek Andhavarapu [abhishek376@gmail.com](mailto:abhishek376@gmail.com) a écrit :

> Hello all,
> 
> I wondering if I can write a faceting query for something like this
> 
> My document structure
> 
> UserID, AnswerID (int array)  
> 1 , [9,10,11,56,78,99]  
> 2 , [10,11,56,78,99]  
> 3 , [8,10,12,56, 79,99]  
> 4 , [9,10,11,56,78,99]
> 
> If want the count of users who answered 9,56 I can write a query. But I have two lists
> 
> List A - 9,10,11  
> ListB - 56,78,99
> 
> I want the permutation of the two lists.
> 
> Count of users who answered [9,56], [9,78], [9,99], [10,56], [10,78], [10,99], [11,56]...
> 
> How do I write a query to achieve something like this.
> 
> Any help is appreciated,
> 
> Thanks.
> 
> --  
> 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:** ![Abhishek\_Andhavarapu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhishek_andhavarapu/32/782_2.png) [@Abhishek\_Andhavarapu](https://discuss.elastic.co/u/Abhishek_Andhavarapu)\
**Post date:** [April 12, 2013, 4:04pm UTC](https://discuss.elastic.co/t/help-needed-for-faceting-query/11557/3 "2013-04-12T16:04:20Z")

</div>

Thanks David. How hard is to implement the functionality I was talking  
about ? Where do I start ?

On Friday, April 12, 2013 1:04:40 AM UTC-6, David Pilato wrote:

> On single value fields, it could work using a script\_field:  
> [Test TermsFacet with script\_field: http://stackoverflow.com/questions/15963088/elasticsearch-faceting-query · GitHub](https://gist.github.com/dadoonet/5370077)  
> I did not find a way to do it on lists. May be Igor or someone else has an  
> idea???
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 12 avr. 2013 à 06:28, Abhishek Andhavarapu \<[abhis...@gmail.com](mailto:abhis...@gmail.com)\<javascript:\>\>  
> a écrit :
> 
> Hello all,
> 
> I wondering if I can write a faceting query for something like this
> 
> My document structure
> 
> UserID, AnswerID (int array)  
> 1 , [9,10,11,56,78,99]  
> 2 , [10,11,56,78,99]  
> 3 , [8,10,12,56, 79,99]  
> 4 , [9,10,11,56,78,99]
> 
> If want the count of users who answered 9,56 I can write a query. But I  
> have two lists
> 
> List A - 9,10,11  
> ListB - 56,78,99
> 
> I want the permutation of the two lists.
> 
> Count of users who answered [9,56], [9,78], [9,99], [10,56], [10,78],  
> [10,99], [11,56]...
> 
> How do I write a query to achieve something like this.
> 
> Any help is appreciated,
> 
> Thanks.
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> 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:41am UTC](https://discuss.elastic.co/t/help-needed-for-faceting-query/11557/4 "2017-07-06T02:41:20Z")

</div>

Closed on July 6, 2017, 2:41am UTC


