# Specific analyzer per document

**URL:** <https://discuss.elastic.co/t/specific-analyzer-per-document/7284>\
**Category:** Elasticsearch\
**Created:** [April 10, 2012, 2:24pm UTC](https://discuss.elastic.co/t/specific-analyzer-per-document/7284 "2012-04-10T14:24:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lyes\_zaiko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lyes_zaiko/32/11250_2.png) [@lyes\_zaiko](https://discuss.elastic.co/u/lyes_zaiko)\
**Post date:** [April 10, 2012, 2:24pm UTC](https://discuss.elastic.co/t/specific-analyzer-per-document/7284/1 "2012-04-10T14:24:49Z")

</div>

Hi all!

I have read in the api documentation that we can set a specific analyzers  
fir a document by setting the "\_analyzer" property in the mapping like this:

{  
"type1" : {  
"\_analyzer" : {  
"path" : "my\_field"  
}  
}  
}

so if I set the analyzer I want to use a specific analyzer dor a document,  
I have to set the value of "my\_field" to its name.

I tried this for my cas, but it does not seem to work

so my mapping is :

{"content": {  
"\_source" : {"enabled" : true},  
"\_uid" : {"index" : "no", "store" : "no"},  
"\_id" : {"index" : "no", "store" : "yes"},  
"\_analyzer" : {"path" : "my\_anal", "index" : "no"},  
"\_index" : {"enabled" : true, "index" : "no", "store" :  
"yes"},  
"properties" : {

"body" : {"type" : "string",  
"store" : "yes",

```
                      "index" : "analyzed",
                      "boost" : 1.0,
                      "term_vector" : "with_positions_offsets"

                      }}

```

}.

The documents I index are like this:  
{"body" : "some data here", "my\_anal" : "french-analyzer"}

where 'french-analyzer' is an anlyzer I defined in the settings

So! what is wrong wth my settings??

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 10, 2012, 8:16pm UTC](https://discuss.elastic.co/t/specific-analyzer-per-document/7284/2 "2012-04-10T20:16:57Z")

</div>

I don't see anything particular wrong with your settings. Are you getting  
an error? If not, why do you think that something is wrong? Can you make  
sure that mappings are applied correctly by running

curl -XGET localhost:9200/your-index/\_mapping

Are specifying proper analyzer for your search queries?

On Tuesday, April 10, 2012 10:24:49 AM UTC-4, lyes zaiko wrote:

> Hi all!
> 
> I have read in the api documentation that we can set a specific analyzers  
> fir a document by setting the "\_analyzer" property in the mapping like this:
> 
> {  
> "type1" : {  
> "\_analyzer" : {  
> "path" : "my\_field"  
> }  
> }  
> }
> 
> so if I set the analyzer I want to use a specific analyzer dor a document,  
> I have to set the value of "my\_field" to its name.
> 
> I tried this for my cas, but it does not seem to work
> 
> so my mapping is :
> 
> {"content": {  
> "\_source" : {"enabled" : true},  
> "\_uid" : {"index" : "no", "store" : "no"},  
> "\_id" : {"index" : "no", "store" : "yes"},  
> "\_analyzer" : {"path" : "my\_anal", "index" : "no"},  
> "\_index" : {"enabled" : true, "index" : "no", "store" :  
> "yes"},  
> "properties" : {
> 
> "body" : {"type" : "string",  
> "store" : "yes",
> 
> ```
> "index" : "analyzed",
> "boost" : 1.0,
> "term_vector" : "with_positions_offsets"
>           
> }}
> 
> ```
> 
> }.
> 
> The documents I index are like this:  
> {"body" : "some data here", "my\_anal" : "french-analyzer"}
> 
> where 'french-analyzer' is an anlyzer I defined in the settings
> 
> So! what is wrong wth my settings??

---

<div class="post-metadata">

**Author:** ![lyes\_zaiko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lyes_zaiko/32/11250_2.png) [@lyes\_zaiko](https://discuss.elastic.co/u/lyes_zaiko)\
**Post date:** [April 11, 2012, 7:28am UTC](https://discuss.elastic.co/t/specific-analyzer-per-document/7284/3 "2012-04-11T07:28:33Z")

</div>

Yes! the mapping is correctly applied. There is no error in the search but  
it seems that the stemming is not well running. My analyzer is correctly  
configured since when I set it statically, it works fine.

On Tue, Apr 10, 2012 at 9:16 PM, Igor Motov [imotov@gmail.com](mailto:imotov@gmail.com) wrote:

> I don't see anything particular wrong with your settings. Are you getting  
> an error? If not, why do you think that something is wrong? Can you make  
> sure that mappings are applied correctly by running
> 
> curl -XGET localhost:9200/your-index/\_mapping
> 
> Are specifying proper analyzer for your search queries?
> 
> On Tuesday, April 10, 2012 10:24:49 AM UTC-4, lyes zaiko wrote:
> 
> > Hi all!
> > 
> > I have read in the api documentation that we can set a specific analyzers  
> > fir a document by setting the "\_analyzer" property in the mapping like this:
> > 
> > {  
> > "type1" : {  
> > "\_analyzer" : {  
> > "path" : "my\_field"  
> > }  
> > }  
> > }
> > 
> > so if I set the analyzer I want to use a specific analyzer dor a  
> > document, I have to set the value of "my\_field" to its name.
> > 
> > I tried this for my cas, but it does not seem to work
> > 
> > so my mapping is :
> > 
> > {"content": {  
> > "\_source" : {"enabled" : true},  
> > "\_uid" : {"index" : "no", "store" : "no"},  
> > "\_id" : {"index" : "no", "store" : "yes"},  
> > "\_analyzer" : {"path" : "my\_anal", "index" : "no"},  
> > "\_index" : {"enabled" : true, "index" : "no", "store" :  
> > "yes"},  
> > "properties" : {
> > 
> > "body" : {"type" : "string",  
> > "store" : "yes",
> > 
> > ```
> > "index" : "analyzed",
> > "boost" : 1.0,
> > "term_vector" : "with_positions_offsets"
> > 
> > }}
> > 
> > ```
> > 
> > }.
> > 
> > The documents I index are like this:  
> > {"body" : "some data here", "my\_anal" : "french-analyzer"}
> > 
> > where 'french-analyzer' is an anlyzer I defined in the settings
> > 
> > So! what is wrong wth my settings??

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 11, 2012, 10:13am UTC](https://discuss.elastic.co/t/specific-analyzer-per-document/7284/4 "2012-04-11T10:13:44Z")

</div>

Could you post a repro to clarify what you mean by "stemming is not well  
running". Here is an example to get you  
started: [Specific analyzer per document repro · GitHub](https://gist.github.com/2358376)

On Wednesday, April 11, 2012 3:28:33 AM UTC-4, lyes zaiko wrote:

> Yes! the mapping is correctly applied. There is no error in the search but  
> it seems that the stemming is not well running. My analyzer is correctly  
> configured since when I set it statically, it works fine.
> 
> On Tue, Apr 10, 2012 at 9:16 PM, Igor Motov [imotov@gmail.com](mailto:imotov@gmail.com) wrote:
> 
> > I don't see anything particular wrong with your settings. Are you getting  
> > an error? If not, why do you think that something is wrong? Can you make  
> > sure that mappings are applied correctly by running
> > 
> > curl -XGET localhost:9200/your-index/\_mapping
> > 
> > Are specifying proper analyzer for your search queries?
> > 
> > On Tuesday, April 10, 2012 10:24:49 AM UTC-4, lyes zaiko wrote:
> > 
> > > Hi all!
> > > 
> > > I have read in the api documentation that we can set a specific  
> > > analyzers fir a document by setting the "\_analyzer" property in the mapping  
> > > like this:
> > > 
> > > {  
> > > "type1" : {  
> > > "\_analyzer" : {  
> > > "path" : "my\_field"  
> > > }  
> > > }  
> > > }
> > > 
> > > so if I set the analyzer I want to use a specific analyzer dor a  
> > > document, I have to set the value of "my\_field" to its name.
> > > 
> > > I tried this for my cas, but it does not seem to work
> > > 
> > > so my mapping is :
> > > 
> > > {"content": {  
> > > "\_source" : {"enabled" : true},  
> > > "\_uid" : {"index" : "no", "store" : "no"},  
> > > "\_id" : {"index" : "no", "store" : "yes"},  
> > > "\_analyzer" : {"path" : "my\_anal", "index" : "no"},  
> > > "\_index" : {"enabled" : true, "index" : "no", "store" :  
> > > "yes"},  
> > > "properties" : {
> > > 
> > > "body" : {"type" : "string",  
> > > "store" : "yes",
> > > 
> > > ```
> > > "index" : "analyzed",
> > > "boost" : 1.0,
> > > "term_vector" : "with_positions_offsets"
> > >           
> > > }}
> > > 
> > > ```
> > > 
> > > }.
> > > 
> > > The documents I index are like this:  
> > > {"body" : "some data here", "my\_anal" : "french-analyzer"}
> > > 
> > > where 'french-analyzer' is an anlyzer I defined in the settings
> > > 
> > > So! what is wrong wth my settings??

---

<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:32am UTC](https://discuss.elastic.co/t/specific-analyzer-per-document/7284/5 "2017-07-06T03:32:57Z")

</div>


