# Does ES support term facet with multiple fields each with a regular expression?

**URL:** <https://discuss.elastic.co/t/does-es-support-term-facet-with-multiple-fields-each-with-a-regular-expression/12331>\
**Category:** Elasticsearch\
**Created:** [June 8, 2013, 10:18pm UTC](https://discuss.elastic.co/t/does-es-support-term-facet-with-multiple-fields-each-with-a-regular-expression/12331 "2013-06-08T22:18:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhoutuo\_Yang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhoutuo_yang/32/2211_2.png) [@Zhoutuo\_Yang](https://discuss.elastic.co/u/Zhoutuo_Yang)\
**Post date:** [June 8, 2013, 10:18pm UTC](https://discuss.elastic.co/t/does-es-support-term-facet-with-multiple-fields-each-with-a-regular-expression/12331/1 "2013-06-08T22:18:43Z")

</div>

Hi all,  
I know ES term facet supports multiple fields and a field with a regular  
expression. But does it support the combination of those?  
If so, a curl example would be appreciated, thank you.

For example, the format of documents is { timestamp: "yyyy.mm.dd", name:  
"firstname.lastname" }  
I want to do term facet on year and first name, If I can use regular  
expression to extract year and firstname from both fields.  
This is just a simple example if you do not understand my question. Plz do  
not suggest to divide fields to smaller ones. That's not my question.  
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:** ![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, 10:36pm UTC](https://discuss.elastic.co/t/does-es-support-term-facet-with-multiple-fields-each-with-a-regular-expression/12331/2 "2013-06-08T22:36:58Z")

</div>

If I understand, you want to use the year from timestamp and lastname from  
the name field to form a facet value such as "Yang 2013"? If yes, you  
would need to do this using a script. Probably native java script so you  
can use some regex patterns to extract the data you want.

Thanks,  
Matt Weber

On Sat, Jun 8, 2013 at 3:18 PM, Zhoutuo Yang [zhoutuoy@gmail.com](mailto:zhoutuoy@gmail.com) wrote:

> Hi all,  
> I know ES term facet supports multiple fields and a field with a regular  
> expression. But does it support the combination of those?  
> If so, a curl example would be appreciated, thank you.
> 
> For example, the format of documents is { timestamp: "yyyy.mm.dd", name:  
> "firstname.lastname" }  
> I want to do term facet on year and first name, If I can use regular  
> expression to extract year and firstname from both fields.  
> This is just a simple example if you do not understand my question. Plz do  
> not suggest to divide fields to smaller ones. That's not my question.  
> 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:** ![Zhoutuo\_Yang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhoutuo_yang/32/2211_2.png) [@Zhoutuo\_Yang](https://discuss.elastic.co/u/Zhoutuo_Yang)\
**Post date:** [June 8, 2013, 10:41pm UTC](https://discuss.elastic.co/t/does-es-support-term-facet-with-multiple-fields-each-with-a-regular-expression/12331/3 "2013-06-08T22:41:26Z")

</div>

Your understanding is correct. Do you mean do not rely on elastic search, I need to do this on my own or using elastic search scripting feature, I haven't looked at it?

--  
Zhoutuo Yang  
Sent with Airmail  
On June 8, 2013 at 3:37:05 PM, Matt Weber ([matt.weber@gmail.com](mailto:matt.weber@gmail.com)) wrote:  
If I understand, you want to use the year from timestamp and lastname from the name field to form a facet value such as "Yang 2013"? If yes, you would need to do this using a script. Probably native java script so you can use some regex patterns to extract the data you want.

Thanks,  
Matt Weber

On Sat, Jun 8, 2013 at 3:18 PM, Zhoutuo Yang [zhoutuoy@gmail.com](mailto:zhoutuoy@gmail.com) wrote:  
Hi all,  
I know ES term facet supports multiple fields and a field with a regular expression. But does it support the combination of those?  
If so, a curl example would be appreciated, thank you.

For example, the format of documents is { timestamp: "yyyy.mm.dd", name: "firstname.lastname" }  
I want to do term facet on year and first name, If I can use regular expression to extract year and firstname from both fields.  
This is just a simple example if you do not understand my question. Plz do not suggest to divide fields to smaller ones. That's not my question.  
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 a topic in the Google Groups "elasticsearch" group.  
To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/vEdkTymhFLA/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/vEdkTymhFLA/unsubscribe?hl=en-US).  
To unsubscribe from this group and all its topics, 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, 10:51pm UTC](https://discuss.elastic.co/t/does-es-support-term-facet-with-multiple-fields-each-with-a-regular-expression/12331/4 "2013-06-08T22:51:03Z")

</div>

Yes, you can't do that without using a script. You can define a script  
field or just use the script option on the terms facet.

Thanks,  
Matt Weber

On Sat, Jun 8, 2013 at 3:41 PM, Zhoutuo Yang [zhoutuoy@gmail.com](mailto:zhoutuoy@gmail.com) wrote:

> Your understanding is correct. Do you mean do not rely on Elasticsearch,  
> I need to do this on my own or using Elasticsearch scripting feature, I  
> haven't looked at it?
> 
> --  
> Zhoutuo Yang  
> Sent with Airmail [http://airmailapp.info/tracking](http://airmailapp.info/tracking)
> 
> On June 8, 2013 at 3:37:05 PM, Matt Weber ([matt.weber@gmail.com](mailto:matt.weber@gmail.com)) wrote:
> 
> If I understand, you want to use the year from timestamp and lastname from  
> the name field to form a facet value such as "Yang 2013"? If yes, you  
> would need to do this using a script. Probably native java script so you  
> can use some regex patterns to extract the data you want.
> 
> Thanks,  
> Matt Weber
> 
> On Sat, Jun 8, 2013 at 3:18 PM, Zhoutuo Yang [zhoutuoy@gmail.com](mailto:zhoutuoy@gmail.com) wrote:
> 
> > Hi all,  
> > I know ES term facet supports multiple fields and a field with a regular  
> > expression. But does it support the combination of those?  
> > If so, a curl example would be appreciated, thank you.
> > 
> > For example, the format of documents is { timestamp: "yyyy.mm.dd", name:  
> > "firstname.lastname" }  
> > I want to do term facet on year and first name, If I can use regular  
> > expression to extract year and firstname from both fields.  
> > This is just a simple example if you do not understand my question. Plz  
> > do not suggest to divide fields to smaller ones. That's not my question.  
> > 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 a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/vEdkTymhFLA/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/vEdkTymhFLA/unsubscribe?hl=en-US)  
> .  
> To unsubscribe from this group and all its topics, 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:** ![Zhoutuo\_Yang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhoutuo_yang/32/2211_2.png) [@Zhoutuo\_Yang](https://discuss.elastic.co/u/Zhoutuo_Yang)\
**Post date:** [June 8, 2013, 10:52pm UTC](https://discuss.elastic.co/t/does-es-support-term-facet-with-multiple-fields-each-with-a-regular-expression/12331/5 "2013-06-08T22:52:15Z")

</div>

Matt, thanks a lot.

--  
Zhoutuo Yang  
Sent with Airmail  
On June 8, 2013 at 3:51:10 PM, Matt Weber ([matt.weber@gmail.com](mailto:matt.weber@gmail.com)) wrote:  
Yes, you can't do that without using a script. You can define a script field or just use the script option on the terms facet.

Thanks,  
Matt Weber

On Sat, Jun 8, 2013 at 3:41 PM, Zhoutuo Yang [zhoutuoy@gmail.com](mailto:zhoutuoy@gmail.com) wrote:  
Your understanding is correct. Do you mean do not rely on elastic search, I need to do this on my own or using elastic search scripting feature, I haven't looked at it?

--  
Zhoutuo Yang  
Sent with Airmail  
On June 8, 2013 at 3:37:05 PM, Matt Weber ([matt.weber@gmail.com](mailto:matt.weber@gmail.com)) wrote:  
If I understand, you want to use the year from timestamp and lastname from the name field to form a facet value such as "Yang 2013"? If yes, you would need to do this using a script. Probably native java script so you can use some regex patterns to extract the data you want.

Thanks,  
Matt Weber

On Sat, Jun 8, 2013 at 3:18 PM, Zhoutuo Yang [zhoutuoy@gmail.com](mailto:zhoutuoy@gmail.com) wrote:  
Hi all,  
I know ES term facet supports multiple fields and a field with a regular expression. But does it support the combination of those?  
If so, a curl example would be appreciated, thank you.

For example, the format of documents is { timestamp: "yyyy.mm.dd", name: "firstname.lastname" }  
I want to do term facet on year and first name, If I can use regular expression to extract year and firstname from both fields.  
This is just a simple example if you do not understand my question. Plz do not suggest to divide fields to smaller ones. That's not my question.  
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 a topic in the Google Groups "elasticsearch" group.  
To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/vEdkTymhFLA/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/vEdkTymhFLA/unsubscribe?hl=en-US).  
To unsubscribe from this group and all its topics, 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 a topic in the Google Groups "elasticsearch" group.  
To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/vEdkTymhFLA/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/vEdkTymhFLA/unsubscribe?hl=en-US).  
To unsubscribe from this group and all its topics, 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:32am UTC](https://discuss.elastic.co/t/does-es-support-term-facet-with-multiple-fields-each-with-a-regular-expression/12331/6 "2017-07-06T02:32:06Z")

</div>


