# \_analyse field: which analyzer will be used on search?

**URL:** <https://discuss.elastic.co/t/-analyse-field-which-analyzer-will-be-used-on-search/8328>\
**Category:** Elasticsearch\
**Created:** [July 5, 2012, 4:07pm UTC](https://discuss.elastic.co/t/-analyse-field-which-analyzer-will-be-used-on-search/8328 "2012-07-05T16:07:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebastien\_Lorber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebastien_lorber/32/2551_2.png) [@Sebastien\_Lorber](https://discuss.elastic.co/u/Sebastien_Lorber)\
**Post date:** [July 5, 2012, 4:07pm UTC](https://discuss.elastic.co/t/-analyse-field-which-analyzer-will-be-used-on-search/8328/1 "2012-07-05T16:07:17Z")

</div>

Hello,

I have a question about the \_analyze field  
[http://www.elasticsearch.org/guide/reference/mapping/analyzer-field.html](http://www.elasticsearch.org/guide/reference/mapping/analyzer-field.html)

This seems pretty cool to handle documents of multiple languages on a  
single index, by detecting first the document language.

However i often read that we should use the same analyzer for indexing and  
searching.  
But in the case of a search of a string text, how can ElasticSearch know  
which search analyzer to use?

Should we handle that ourselves when building our query? (quite a pain)  
Or perhaps ES is doing some magical stuff like applying all the analyzers  
known for that field and creates automatically a boolean query with all  
these analyzers?  
Please tell me 🙂

Btw is it possible to put the \_analyzer field only for a specific field  
instead of declaring it directly for a type?  
For exemple if i know by statistics that my user is posting 80% of  
documents in english, and 20% in french, i would like to have a multi\_field  
which define 3 subfields "untouched" "preferedLang1" and "preferedLang2"  
Is it possible do do such a thing?

Thanks

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [July 6, 2012, 9:14pm UTC](https://discuss.elastic.co/t/-analyse-field-which-analyzer-will-be-used-on-search/8328/2 "2012-07-06T21:14:54Z")

</div>

It is possible to specify the analyzer for each field. In fact, it is  
the normal way to use analyzers. There is also the \_all analyzer,  
which would be used by default if you do not specify a field.

Your use of multi-field is correct and is a perfect use case.

--  
Ivan

On Thu, Jul 5, 2012 at 9:07 AM, Sébastien Lorber  
[lorber.sebastien@gmail.com](mailto:lorber.sebastien@gmail.com) wrote:

> Btw is it possible to put the \_analyzer field only for a specific field  
> instead of declaring it directly for a type?  
> For exemple if i know by statistics that my user is posting 80% of documents  
> in english, and 20% in french, i would like to have a multi\_field which  
> define 3 subfields "untouched" "preferedLang1" and "preferedLang2"  
> Is it possible do do such a thing?
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![Sebastien\_Lorber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebastien_lorber/32/2551_2.png) [@Sebastien\_Lorber](https://discuss.elastic.co/u/Sebastien_Lorber)\
**Post date:** [July 6, 2012, 10:27pm UTC](https://discuss.elastic.co/t/-analyse-field-which-analyzer-will-be-used-on-search/8328/3 "2012-07-06T22:27:32Z")

</div>

Sorry i don't talk about the "analyzer" field of properties, but the  
\_analyzer field which seems to be configured on the type only in the  
documentation.

It's not the same, here i'm trying to index the same field (even a subfield  
of a multifield) with multiple analyzers, according to the document  
country, instead to have a big multi\_field with each subfield using a  
country specific analyzer.

Le vendredi 6 juillet 2012 23:14:54 UTC+2, Ivan Brusic a écrit :

> It is possible to specify the analyzer for each field. In fact, it is  
> the normal way to use analyzers. There is also the \_all analyzer,  
> which would be used by default if you do not specify a field.
> 
> Your use of multi-field is correct and is a perfect use case.
> 
> --  
> Ivan
> 
> On Thu, Jul 5, 2012 at 9:07 AM, Sébastien Lorber  
> [lorber.sebastien@gmail.com](mailto:lorber.sebastien@gmail.com) wrote:
> 
> > Btw is it possible to put the \_analyzer field only for a specific field  
> > instead of declaring it directly for a type?  
> > For exemple if i know by statistics that my user is posting 80% of  
> > documents  
> > in english, and 20% in french, i would like to have a multi\_field which  
> > define 3 subfields "untouched" "preferedLang1" and "preferedLang2"  
> > Is it possible do do such a thing?
> > 
> > Thanks

---

<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, 3:21am UTC](https://discuss.elastic.co/t/-analyse-field-which-analyzer-will-be-used-on-search/8328/4 "2017-07-06T03:21:10Z")

</div>


