# Generate two terms in facets

**URL:** <https://discuss.elastic.co/t/generate-two-terms-in-facets/12328>\
**Category:** Elasticsearch\
**Created:** [June 8, 2013, 3:20pm UTC](https://discuss.elastic.co/t/generate-two-terms-in-facets/12328 "2013-06-08T15:20:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Murilo\_de\_Souza\_Lope](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/murilo_de_souza_lope/32/2292_2.png) [@Murilo\_de\_Souza\_Lope](https://discuss.elastic.co/u/Murilo_de_Souza_Lope)\
**Post date:** [June 8, 2013, 3:20pm UTC](https://discuss.elastic.co/t/generate-two-terms-in-facets/12328/1 "2013-06-08T15:20:21Z")

</div>

I am trying to generate two terms in the same facets, for example:

"terms": [{  
"term": "term value",  
"termtwo": "term value",  
"count": 0  
} ..

But only comes with 1 "term"

"terms": [{  
"term": "term value",  
"count": 0  
} ..

I've tried using the "multi fields", in indexing, but without success.

Anyone know of any examples or concept sure how to do this?

thank you

--  
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:** [June 8, 2013, 4:48pm UTC](https://discuss.elastic.co/t/generate-two-terms-in-facets/12328/2 "2013-06-08T16:48:06Z")

</div>

Ask for two facets. One for each field.

My 2 cents

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

Le 8 juin 2013 à 17:20, Murilo de Souza Lopes [murilosl@gmail.com](mailto:murilosl@gmail.com) a écrit :

> I am trying to generate two terms in the same facets, for example:
> 
> "terms": [{  
> "term": "term value",  
> "termtwo": "term value",  
> "count": 0  
> } ..
> 
> But only comes with 1 "term"
> 
> "terms": [{  
> "term": "term value",  
> "count": 0  
> } ..
> 
> I've tried using the "multi fields", in indexing, but without success.
> 
> Anyone know of any examples or concept sure how to do this?
> 
> ## thank you
> 
> 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:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [June 8, 2013, 5:35pm UTC](https://discuss.elastic.co/t/generate-two-terms-in-facets/12328/3 "2013-06-08T17:35:15Z")

</div>

Or use the fields parameter on the terms facet which allows faceting over  
multiple fields.

{  
"query" : {  
"match\_all" : { }  
},  
"facets" : {  
"tags" : {  
"terms" : {  
"fields" : ["field1", "field2"]  
}  
}  
}  
}

On Sat, Jun 8, 2013 at 9:48 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Ask for two facets. One for each field.
> 
> My 2 cents
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 8 juin 2013 à 17:20, Murilo de Souza Lopes [murilosl@gmail.com](mailto:murilosl@gmail.com) a  
> écrit :
> 
> I am trying to generate two terms in the same facets, for example:
> 
> "terms": [{  
> "term": "term value",  
> "termtwo": "term value",  
> "count": 0  
> } ..
> 
> But only comes with 1 "term"
> 
> "terms": [{  
> "term": "term value",  
> "count": 0  
> } ..
> 
> I've tried using the "multi fields", in indexing, but without success.
> 
> Anyone know of any examples or concept sure how to do this?
> 
> thank you
> 
> --  
> 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).

--  
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:** ![Murilo\_de\_Souza\_Lope](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/murilo_de_souza_lope/32/2292_2.png) [@Murilo\_de\_Souza\_Lope](https://discuss.elastic.co/u/Murilo_de_Souza_Lope)\
**Post date:** [June 8, 2013, 7:37pm UTC](https://discuss.elastic.co/t/generate-two-terms-in-facets/12328/4 "2013-06-08T19:37:58Z")

</div>

I think the problem is the gem tire, because I'm trying to add + 1 terms in  
facet it is only generating 1.

someone working with the tire here?

Thanks for the replies.

Em sábado, 8 de junho de 2013 12h20min21s UTC-3, Murilo de Souza Lopes  
escreveu:

> I am trying to generate two terms in the same facets, for example:
> 
> "terms": [{  
> "term": "term value",  
> "termtwo": "term value",  
> "count": 0  
> } ..
> 
> But only comes with 1 "term"
> 
> "terms": [{  
> "term": "term value",  
> "count": 0  
> } ..
> 
> I've tried using the "multi fields", in indexing, but without success.
> 
> Anyone know of any examples or concept sure how to do this?
> 
> thank you

--  
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:** ![Kiranpvuthaman](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@Kiranpvuthaman](https://discuss.elastic.co/u/Kiranpvuthaman)\
**Post date:** [June 8, 2013, 8:42pm UTC](https://discuss.elastic.co/t/generate-two-terms-in-facets/12328/5 "2013-06-08T20:42:41Z")

</div>

Hi All,

I also having a similar requirement.  
My collection have sub documents and the sub document contains three  
properties (Code, Description and Type). I basically wants to get distinct  
Code, Description and Type as TERM from the sub document (may be separated  
with some characters in between) and I want to display all three values in  
the interface.

Thanks in advance.  
Regards,  
Kiran

On Sunday, June 9, 2013 1:07:58 AM UTC+5:30, Murilo de Souza Lopes wrote:

> I think the problem is the gem tire, because I'm trying to add + 1 terms  
> in facet it is only generating 1.
> 
> someone working with the tire here?
> 
> Thanks for the replies.
> 
> Em sábado, 8 de junho de 2013 12h20min21s UTC-3, Murilo de Souza Lopes  
> escreveu:
> 
> > I am trying to generate two terms in the same facets, for example:
> > 
> > "terms": [{  
> > "term": "term value",  
> > "termtwo": "term value",  
> > "count": 0  
> > } ..
> > 
> > But only comes with 1 "term"
> > 
> > "terms": [{  
> > "term": "term value",  
> > "count": 0  
> > } ..
> > 
> > I've tried using the "multi fields", in indexing, but without success.
> > 
> > Anyone know of any examples or concept sure how to do this?
> > 
> > thank you

--  
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:** ![sslhj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sslhj/32/119856_2.png) [@sslhj](https://discuss.elastic.co/u/sslhj)\
**Post date:** [June 9, 2013, 1:23am UTC](https://discuss.elastic.co/t/generate-two-terms-in-facets/12328/6 "2013-06-09T01:23:45Z")

</div>

hi all,  
I have save requirement. my solution is, do term facet against each field, and add bool filter, which 'must' term filters against other fields, into it.

Hi All,

I also having a similar requirement.  
My collection have sub documents and the sub document contains three  
properties (Code, Description and Type). I basically wants to get distinct  
Code, Description and Type as TERM from the sub document (may be separated  
with some characters in between) and I want to display all three values in  
the interface.

Thanks in advance.  
Regards,  
Kiran

On Sunday, June 9, 2013 1:07:58 AM UTC+5:30, Murilo de Souza Lopes wrote:

> I think the problem is the gem tire, because I'm trying to add + 1 terms  
> in facet it is only generating 1.
> 
> someone working with the tire here?
> 
> Thanks for the replies.
> 
> Em sábado, 8 de junho de 2013 12h20min21s UTC-3, Murilo de Souza Lopes  
> escreveu:
> 
> > I am trying to generate two terms in the same facets, for example:
> > 
> > "terms": [{  
> > "term": "term value",  
> > "termtwo": "term value",  
> > "count": 0  
> > } ..
> > 
> > But only comes with 1 "term"
> > 
> > "terms": [{  
> > "term": "term value",  
> > "count": 0  
> > } ..
> > 
> > I've tried using the "multi fields", in indexing, but without success.
> > 
> > Anyone know of any examples or concept sure how to do this?
> > 
> > thank you

--  
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@.  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![sujoysett](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@sujoysett](https://discuss.elastic.co/u/sujoysett)\
**Post date:** [June 10, 2013, 1:18pm UTC](https://discuss.elastic.co/t/generate-two-terms-in-facets/12328/7 "2013-06-10T13:18:21Z")

</div>

Hi

I did it by using scripts and parsing the response at client side.

{  
"size": 0,  
"facets": {  
"my\_facet": {  
"terms": {  
"script\_field": "\_source.field1 + ' ~~~' + \_source.field2",  
"size": 10  
}  
}  
}  
}

Possible to do on any number of fields, but this concepts does not work so  
great when nested arrays or multi-valued fields are involved.  
Also its memory intensive.

- Sujoy.

On Sunday, June 9, 2013 2:12:41 AM UTC+5:30, Kiran Uthaman wrote:

> Hi All,
> 
> I also having a similar requirement.  
> My collection have sub documents and the sub document contains three  
> properties (Code, Description and Type). I basically wants to get distinct  
> Code, Description and Type as TERM from the sub document (may be separated  
> with some characters in between) and I want to display all three values in  
> the interface.
> 
> Thanks in advance.  
> Regards,  
> Kiran
> 
> On Sunday, June 9, 2013 1:07:58 AM UTC+5:30, Murilo de Souza Lopes wrote:
> 
> > I think the problem is the gem tire, because I'm trying to add + 1 terms  
> > in facet it is only generating 1.
> > 
> > someone working with the tire here?
> > 
> > Thanks for the replies.
> > 
> > Em sábado, 8 de junho de 2013 12h20min21s UTC-3, Murilo de Souza Lopes  
> > escreveu:
> > 
> > > I am trying to generate two terms in the same facets, for example:
> > > 
> > > "terms": [{  
> > > "term": "term value",  
> > > "termtwo": "term value",  
> > > "count": 0  
> > > } ..
> > > 
> > > But only comes with 1 "term"
> > > 
> > > "terms": [{  
> > > "term": "term value",  
> > > "count": 0  
> > > } ..
> > > 
> > > I've tried using the "multi fields", in indexing, but without success.
> > > 
> > > Anyone know of any examples or concept sure how to do this?
> > > 
> > > thank you

--  
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:** ![Murilo\_de\_Souza\_Lope](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/murilo_de_souza_lope/32/2292_2.png) [@Murilo\_de\_Souza\_Lope](https://discuss.elastic.co/u/Murilo_de_Souza_Lope)\
**Post date:** [June 10, 2013, 5:23pm UTC](https://discuss.elastic.co/t/generate-two-terms-in-facets/12328/8 "2013-06-10T17:23:43Z")

</div>

thanks for the tip

2013/6/10 Sujoy Sett [sujoysett@gmail.com](mailto:sujoysett@gmail.com)

> Hi
> 
> I did it by using scripts and parsing the response at client side.
> 
> {  
> "size": 0,  
> "facets": {  
> "my\_facet": {  
> "terms": {  
> "script\_field": "\_source.field1 + ' ~~~' +  
> \_source.field2",  
> "size": 10  
> }  
> }  
> }  
> }
> 
> Possible to do on any number of fields, but this concepts does not work so  
> great when nested arrays or multi-valued fields are involved.  
> Also its memory intensive.
> 
> - Sujoy.
> 
> On Sunday, June 9, 2013 2:12:41 AM UTC+5:30, Kiran Uthaman wrote:
> 
> > Hi All,
> > 
> > I also having a similar requirement.  
> > My collection have sub documents and the sub document contains three  
> > properties (Code, Description and Type). I basically wants to get distinct  
> > Code, Description and Type as TERM from the sub document (may be separated  
> > with some characters in between) and I want to display all three values in  
> > the interface.
> > 
> > Thanks in advance.  
> > Regards,  
> > Kiran
> > 
> > On Sunday, June 9, 2013 1:07:58 AM UTC+5:30, Murilo de Souza Lopes wrote:
> > 
> > > I think the problem is the gem tire, because I'm trying to add + 1 terms  
> > > in facet it is only generating 1.
> > > 
> > > someone working with the tire here?
> > > 
> > > Thanks for the replies.
> > > 
> > > Em sábado, 8 de junho de 2013 12h20min21s UTC-3, Murilo de Souza Lopes  
> > > escreveu:
> > > 
> > > > I am trying to generate two terms in the same facets, for example:
> > > > 
> > > > "terms": [{  
> > > > "term": "term value",  
> > > > "termtwo": "term value",  
> > > > "count": 0  
> > > > } ..
> > > > 
> > > > But only comes with 1 "term"
> > > > 
> > > > "terms": [{  
> > > > "term": "term value",  
> > > > "count": 0  
> > > > } ..
> > > > 
> > > > I've tried using the "multi fields", in indexing, but without success.
> > > > 
> > > > Anyone know of any examples or concept sure how to do this?
> > > > 
> > > > thank you
> > > 
> > > --  
> > > 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).

--  
Murilo de Souza Lopes

--  
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:31am UTC](https://discuss.elastic.co/t/generate-two-terms-in-facets/12328/9 "2017-07-06T02:31:59Z")

</div>


