# Using analyzers based on language detection

**URL:** <https://discuss.elastic.co/t/using-analyzers-based-on-language-detection/19503>\
**Category:** Elasticsearch\
**Created:** [August 28, 2014, 6:42am UTC](https://discuss.elastic.co/t/using-analyzers-based-on-language-detection/19503 "2014-08-28T06:42:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nitin\_Maheshwari](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@Nitin\_Maheshwari](https://discuss.elastic.co/u/Nitin_Maheshwari)\
**Post date:** [August 28, 2014, 6:42am UTC](https://discuss.elastic.co/t/using-analyzers-based-on-language-detection/19503/1 "2014-08-28T06:42:26Z")

</div>

Hi,

I am using langdetect plugin to dynamically assign the analyzer at index  
time.

PUT test  
POST test/article/\_mapping  
{  
"article" : {  
"\_analyzer" : {  
"path" : "description.lang"  
},  
"properties" : {  
"description" : { "type" : "langdetect" }  
}  
}  
}

Langdetect plugin detects the language as 'en', 'fr', 'de', and so on. so  
the analyzers should be defined as 'en', etc. This make them less  
descriptive and the context of analyzer is lost. Is it possible to derive a  
more descriptive name, such that \_analyzer is resolve to 'en\_icu\_analyzer',  
instead of just 'en'?

Something like... (this does not work), this is just what i want to  
achieve.

article" : {  
"\_analyzer" : {  
"path" : "description.lang" + "\_icu\_analyzer"  
}

Another question - is it possible to define analyzer dynamically at field  
level rather than at the index level?

Thanks,  
Nitin

--  
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/fc1b9d30-0200-411c-8bba-8939c7f87fe3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fc1b9d30-0200-411c-8bba-8939c7f87fe3%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [August 28, 2014, 7:07am UTC](https://discuss.elastic.co/t/using-analyzers-based-on-language-detection/19503/2 "2014-08-28T07:07:08Z")

</div>

This requires a change in the langdetect plugin, feel free to open an issue  
at

> **[Issues · jprante/elasticsearch-langdetect](https://github.com/jprante/elasticsearch-langdetect/issues)**
>
> A plugin for language detection in Elasticsearch using Nakatani Shuyo's language detector - Issues · jprante/elasticsearch-langdetect

It should be trivial to wrap something like a String.format() around the  
language name by config request.

Jörg

On Thu, Aug 28, 2014 at 8:42 AM, Nitin Maheshwari [ask4nitin@gmail.com](mailto:ask4nitin@gmail.com)  
wrote:

> Hi,
> 
> I am using langdetect plugin to dynamically assign the analyzer at index  
> time.
> 
> PUT test  
> POST test/article/\_mapping  
> {  
> "article" : {  
> "\_analyzer" : {  
> "path" : "description.lang"  
> },  
> "properties" : {  
> "description" : { "type" : "langdetect" }  
> }  
> }  
> }
> 
> Langdetect plugin detects the language as 'en', 'fr', 'de', and so on. so  
> the analyzers should be defined as 'en', etc. This make them less  
> descriptive and the context of analyzer is lost. Is it possible to derive a  
> more descriptive name, such that \_analyzer is resolve to 'en\_icu\_analyzer',  
> instead of just 'en'?
> 
> Something like... (this does not work), this is just what i want to  
> achieve.
> 
> article" : {  
> "\_analyzer" : {  
> "path" : "description.lang" + "\_icu\_analyzer"  
> }
> 
> Another question - is it possible to define analyzer dynamically at field  
> level rather than at the index level?
> 
> Thanks,  
> Nitin
> 
> --  
> 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/fc1b9d30-0200-411c-8bba-8939c7f87fe3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fc1b9d30-0200-411c-8bba-8939c7f87fe3%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/fc1b9d30-0200-411c-8bba-8939c7f87fe3%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/fc1b9d30-0200-411c-8bba-8939c7f87fe3%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/CAKdsXoHDq%3DX4%3D19YKFV4rnX%3DKeoRSwm%3D6sjSNVya\_A8hbXeZ\_A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHDq%3DX4%3D19YKFV4rnX%3DKeoRSwm%3D6sjSNVya_A8hbXeZ_A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Nitin\_Maheshwari](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@Nitin\_Maheshwari](https://discuss.elastic.co/u/Nitin_Maheshwari)\
**Post date:** [August 28, 2014, 8:54am UTC](https://discuss.elastic.co/t/using-analyzers-based-on-language-detection/19503/3 "2014-08-28T08:54:56Z")

</div>

Done: [Allow formating the detected language output string as output · Issue #20 · jprante/elasticsearch-langdetect · GitHub](https://github.com/jprante/elasticsearch-langdetect/issues/20)

Thanks.

On Thursday, 28 August 2014 12:12:26 UTC+5:30, Nitin Maheshwari wrote:

> Hi,
> 
> I am using langdetect plugin to dynamically assign the analyzer at index  
> time.
> 
> PUT test  
> POST test/article/\_mapping  
> {  
> "article" : {  
> "\_analyzer" : {  
> "path" : "description.lang"  
> },  
> "properties" : {  
> "description" : { "type" : "langdetect" }  
> }  
> }  
> }
> 
> Langdetect plugin detects the language as 'en', 'fr', 'de', and so on. so  
> the analyzers should be defined as 'en', etc. This make them less  
> descriptive and the context of analyzer is lost. Is it possible to derive a  
> more descriptive name, such that \_analyzer is resolve to 'en\_icu\_analyzer',  
> instead of just 'en'?
> 
> Something like... (this does not work), this is just what i want to  
> achieve.
> 
> article" : {  
> "\_analyzer" : {  
> "path" : "description.lang" + "\_icu\_analyzer"  
> }
> 
> Another question - is it possible to define analyzer dynamically at field  
> level rather than at the index level?
> 
> Thanks,  
> Nitin

--  
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/b085839f-91d5-4d81-bd17-091b9c317324%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b085839f-91d5-4d81-bd17-091b9c317324%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:05am UTC](https://discuss.elastic.co/t/using-analyzers-based-on-language-detection/19503/4 "2017-07-06T01:05:51Z")

</div>


