# Using different analyzers for a single field (depends on condition)

**URL:** <https://discuss.elastic.co/t/using-different-analyzers-for-a-single-field-depends-on-condition/17328>\
**Category:** Elasticsearch\
**Created:** [May 3, 2014, 6:58am UTC](https://discuss.elastic.co/t/using-different-analyzers-for-a-single-field-depends-on-condition/17328 "2014-05-03T06:58:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loic\_Wenkin](https://avatars.discourse-cdn.com/v4/letter/l/4491bb/32.png) [@Loic\_Wenkin](https://discuss.elastic.co/u/Loic_Wenkin)\
**Post date:** [May 3, 2014, 6:58am UTC](https://discuss.elastic.co/t/using-different-analyzers-for-a-single-field-depends-on-condition/17328/1 "2014-05-03T06:58:51Z")

</div>

Hello everybody,

I was just wondering if it could be possible to use different analyzers for  
a field which is present in different nested elements. To be more clear,  
this is what I would like to do :

Imagine I have this kind of structure :

{  
a: [  
{  
text: blabla,  
language: fr  
},  
{  
text: toto,  
language: en  
}  
]  
}

What I would like to do is using french analyzer for text with "language:  
fr", and english (or standard) analyzer for texy with "language: en". From  
what I read, it's not possible, but I would like to know if someone have  
found a solution to do this. What I am doing in order to do this is using a  
structure like this:

{  
a: {  
fr: {  
text: blabla  
},  
en: {  
text: toto  
}  
}  
}

Using this, I can specify analyzers with the full path, but it could be  
great if I can specify analyzers as explained in the first structure (using  
script, or a kind of conditionnal analyzer or ...).

Any help would be appreciated 🙂

Regards,  
Loïc

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5d4ac492-bf17-40af-a4c3-c99696f19ad3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5d4ac492-bf17-40af-a4c3-c99696f19ad3%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 5, 2014, 11:21am UTC](https://discuss.elastic.co/t/using-different-analyzers-for-a-single-field-depends-on-condition/17328/2 "2014-05-05T11:21:30Z")

</div>

Hey,

using different analyzers in one document, which are extracted from the  
document is not possible. However if you have one document per language,  
you could use the \_analyzer capability for this, see

> **[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.

Hope this helps...

--Alex

On Sat, May 3, 2014 at 8:58 AM, Loïc Wenkin [loic.wenkin@gmail.com](mailto:loic.wenkin@gmail.com) wrote:

> Hello everybody,
> 
> I was just wondering if it could be possible to use different analyzers  
> for a field which is present in different nested elements. To be more  
> clear, this is what I would like to do :
> 
> Imagine I have this kind of structure :
> 
> {  
> a: [  
> {  
> text: blabla,  
> language: fr  
> },  
> {  
> text: toto,  
> language: en  
> }  
> ]  
> }
> 
> What I would like to do is using french analyzer for text with "language:  
> fr", and english (or standard) analyzer for texy with "language: en". From  
> what I read, it's not possible, but I would like to know if someone have  
> found a solution to do this. What I am doing in order to do this is using a  
> structure like this:
> 
> {  
> a: {  
> fr: {  
> text: blabla  
> },  
> en: {  
> text: toto  
> }  
> }  
> }
> 
> Using this, I can specify analyzers with the full path, but it could be  
> great if I can specify analyzers as explained in the first structure (using  
> script, or a kind of conditionnal analyzer or ...).
> 
> Any help would be appreciated 🙂
> 
> Regards,  
> Loïc
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/5d4ac492-bf17-40af-a4c3-c99696f19ad3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5d4ac492-bf17-40af-a4c3-c99696f19ad3%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/5d4ac492-bf17-40af-a4c3-c99696f19ad3%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5d4ac492-bf17-40af-a4c3-c99696f19ad3%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM\_2cUCA6Ks8C%2BN0BAtE0ZxY\_-yxiOjYt\_of25Z-omtKgg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM_2cUCA6Ks8C%2BN0BAtE0ZxY_-yxiOjYt_of25Z-omtKgg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Loic\_Wenkin](https://avatars.discourse-cdn.com/v4/letter/l/4491bb/32.png) [@Loic\_Wenkin](https://discuss.elastic.co/u/Loic_Wenkin)\
**Post date:** [May 5, 2014, 4:55pm UTC](https://discuss.elastic.co/t/using-different-analyzers-for-a-single-field-depends-on-condition/17328/3 "2014-05-05T16:55:57Z")

</div>

Hello Alex,

Thanks for your reply. I have already looked at the \_analyzer capability,  
but it doesn't help me. I will continue using the structure I described  
above.

Loïc

Le lundi 5 mai 2014 13:21:30 UTC+2, Alexander Reelsen a écrit :

> Hey,
> 
> using different analyzers in one document, which are extracted from the  
> document is not possible. However if you have one document per language,  
> you could use the \_analyzer capability for this, see  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-analyzer-field.html#mapping-analyzer-field)
> 
> Hope this helps...
> 
> --Alex
> 
> On Sat, May 3, 2014 at 8:58 AM, Loïc Wenkin \<[loic....@gmail.com](mailto:loic....@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hello everybody,
> > 
> > I was just wondering if it could be possible to use different analyzers  
> > for a field which is present in different nested elements. To be more  
> > clear, this is what I would like to do :
> > 
> > Imagine I have this kind of structure :
> > 
> > {  
> > a: [  
> > {  
> > text: blabla,  
> > language: fr  
> > },  
> > {  
> > text: toto,  
> > language: en  
> > }  
> > ]  
> > }
> > 
> > What I would like to do is using french analyzer for text with "language:  
> > fr", and english (or standard) analyzer for texy with "language: en". From  
> > what I read, it's not possible, but I would like to know if someone have  
> > found a solution to do this. What I am doing in order to do this is using a  
> > structure like this:
> > 
> > {  
> > a: {  
> > fr: {  
> > text: blabla  
> > },  
> > en: {  
> > text: toto  
> > }  
> > }  
> > }
> > 
> > Using this, I can specify analyzers with the full path, but it could be  
> > great if I can specify analyzers as explained in the first structure (using  
> > script, or a kind of conditionnal analyzer or ...).
> > 
> > Any help would be appreciated 🙂
> > 
> > Regards,  
> > Loïc
> > 
> > --  
> > 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:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/5d4ac492-bf17-40af-a4c3-c99696f19ad3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5d4ac492-bf17-40af-a4c3-c99696f19ad3%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/5d4ac492-bf17-40af-a4c3-c99696f19ad3%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5d4ac492-bf17-40af-a4c3-c99696f19ad3%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a0f3e59c-495d-4c54-9133-fd84e932b2b3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a0f3e59c-495d-4c54-9133-fd84e932b2b3%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:31am UTC](https://discuss.elastic.co/t/using-different-analyzers-for-a-single-field-depends-on-condition/17328/4 "2017-07-06T01:31:35Z")

</div>


