# Configured custom analyzer registered but not used while indexing

**URL:** <https://discuss.elastic.co/t/configured-custom-analyzer-registered-but-not-used-while-indexing/19360>\
**Category:** Elasticsearch\
**Created:** [August 20, 2014, 10:28am UTC](https://discuss.elastic.co/t/configured-custom-analyzer-registered-but-not-used-while-indexing/19360 "2014-08-20T10:28:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phoenix](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phoenix/32/1319_2.png) [@phoenix](https://discuss.elastic.co/u/phoenix)\
**Post date:** [August 20, 2014, 10:28am UTC](https://discuss.elastic.co/t/configured-custom-analyzer-registered-but-not-used-while-indexing/19360/1 "2014-08-20T10:28:23Z")

</div>

Hi everyone,

I'm facing a curious problem.

I configured a custom analyzer this way in my settings :

{  
"_index_":{  
"_cluster.name_":"test-cluster",  
"_client.transport.sniff_":true,  
"_analysis_":{  
"_filter_":{  
"_french\_elision_":{  
"type":"elision",  
"articles":[  
\* ...skipped...\*  
]  
},  
"_french\_stop_":{  
"type":"stop",  
"stopwords":"_french_",  
"ignore\_case":true  
},  
"_snowball_":{  
"type":"snowball",  
"language":"french"  
}  
},  
"_analyzer_":{

- "my\_french":{ "type":"custom",  
"tokenizer":"standard", "filter":[  
"french\_elision", "lowercase",  
"french\_stop", "snowball" ] },\*  
"_lower\_analyzer_":{  
"type":"custom",  
"tokenizer":"keyword",  
"filter":"lowercase"  
},  
"_token\_analyzer_":{  
"type":"custom",  
"tokenizer":"whitespace"  
}  
}  
}  
}  
}

My mapping declares the custom analyzer as the global analyzer for the type  
'_record_', and explicitly for the '_a_' field of my records this way :

{  
"_record_":{  
"_\_all_":{  
"enabled":false  
},  
\* "analyzer":"my\_french",\*  
"_properties_":{  
"_\_uuid_":{  
"type":"string",  
"store":"yes",  
"index":"not\_analyzed"  
},  
"_a_":{  
"_type_":"multi\_field",  
"_fields_":{  
"a":{  
"type":"string",  
"store":"yes",  
"index":"analyzed",  
\*"analyzer":"my\_french" \*  
},  
"_raw_":{  
"type":"string",  
"store":"no",  
"index":"not\_analyzed"  
},  
"_tokens_":{  
"type":"string",  
"store":"no",  
"index":"analyzed",  
"analyzer":"token\_analyzer"  
},  
"_lower_":{  
"type":"string",  
"store":"no",  
"index":"analyzed",  
"analyzer":"lower\_analyzer"  
}  
}  
},  
"_g\_r_":{  
"type":"string",  
"store":"yes",  
"index":"analyzed"  
}  
}  
}  
}

So here basically, i expect to see fields _a_ and _g\_r_ to be analysed  
using _my\_french_ analyzer:

- _a_ because it is explicitly defined in the field mapping;
- _g\_r_ because no analyzer is defined in the field mapping, but the global  
analyzer is defined to my\_french.

And actually if i test the analysis process using a \_analyze REST request,  
it seems ok :

$ curl -XGET 'localhost:9200/test-index/\_analyze?analyzer=_my\_french_' -d "_j'aime  
les chevaux_"  
{  
"_tokens_":[  
{  
"token":"_aim_",  
"start\_offset":0,  
"end\_offset":6,  
"type":"",  
"position":1  
},  
{  
"token":"_cheval_",  
"start\_offset":11,  
"end\_offset":18,  
"type":"",  
"position":3  
}  
]  
}

Which is definitely what i expect of my my\_french analyzer.

But when i index my data and query on it, i don't get the expected results.  
So i tried executing a facet query to see what terms have been indexed for  
my fields, and the result is very surprising :

Query :

{  
"_query_": {  
"_match_": {  
"\_id": "12"  
}  
},  
"_facets_": {  
"_tokens_": {  
"_terms_": {  
"_field_": "_a_"  
}  
}  
}  
}

This gives me the following result, which is not what i expected to see (i  
expect the tokens to be returned to be _aim_ and _cheval_, as resulting  
from the analysis request above) :

$ curl -X POST "[http://localhost:9200/test-index/\_search?pretty=true](http://localhost:9200/test-index/_search?pretty=true)" -d  
'{"query": {"match": {"\_id": "12"}},"facets": {"tokens": {"terms":  
{"field": "a"}}}}'

{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"_hits_" : {  
"_total_" : 1,  
"max\_score" : 1.0,  
"_hits_" : [ {  
"\_index" : "test-index",  
"\_type" : "record",  
"\_id" : "12",  
"\_score" : 1.0,  
"\_source":{"\_uuid":"12","a\_t":false,"a\_n":false,"a":"J'aime les  
chevaux","b\_r":null,"b\_t":false,"b\_n":false,"b":1407664800000,"c\_r":null,"c\_t":false,"c\_n":false,"c":2,"d\_r":"m3","d\_t":true,"d\_n":false,"d":null,"e\_r":null,"e\_t":false,"e\_n":true,"e":12,"f\_r":null,"f\_t":false,"f\_n":false,"f":true,"g\_r":"J'aime  
les chevaux","g\_t":false,"g\_n":false,"g":12.0}  
} ]  
},  
"_facets_" : {  
"_tokens_" : {  
"_\_type_" : "_terms_",  
"missing" : 0,  
"total" : 2,  
"other" : 0,  
"_terms_" : [ {  
"_term_" : "_j'aim_",  
"count" : 1  
}, {  
"_term_" : "_cheval_",  
"count" : 1  
} ]  
}  
}  
}

Can anyone see what is wrong, where i made a mistake, or what i am missing ?

--  
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/9e11d3ef-b291-44d8-a08a-3d7f5740badb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9e11d3ef-b291-44d8-a08a-3d7f5740badb%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:07am UTC](https://discuss.elastic.co/t/configured-custom-analyzer-registered-but-not-used-while-indexing/19360/2 "2017-07-06T01:07:30Z")

</div>


