# Analysis Mismatch in Elastic Search

**URL:** <https://discuss.elastic.co/t/analysis-mismatch-in-elastic-search/5514>\
**Category:** Elasticsearch\
**Created:** [October 4, 2011, 7:26pm UTC](https://discuss.elastic.co/t/analysis-mismatch-in-elastic-search/5514 "2011-10-04T19:26:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neil1](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@Neil1](https://discuss.elastic.co/u/Neil1)\
**Post date:** [October 4, 2011, 7:26pm UTC](https://discuss.elastic.co/t/analysis-mismatch-in-elastic-search/5514/1 "2011-10-04T19:26:24Z")

</div>

I have the following configuration in elasticsearch defined below.  
The problem is that I'm not getting  
back the results I expect. What's odd is that I'm taking exactly what  
I am doing in solr and trying to  
apply it to elastic search.

Given that I have no way to analyze what's going on in elastic search,  
I'm at a loss to further troubleshoot  
why things are working as they would expect.

Essentially using the query\_string on "ja" in elastic search is not  
returning: "627 Lb Woman Jackies Story"  
even though that document exists in the index.

Any help is appreciated.

Thanks,

Neil

elasticsearch.yml

analysis:  
analyzer:  
containsText:  
tokenizer: whitespace  
filter: [asciifolding, lowercase, autocomplete]  
filter:  
autocomplete:  
type: edgeNGram  
min\_gram: 1  
max\_gram: 100  
side: front

mapper:  
program:  
properties:  
autoCompleteContainsProgramTitle: {"type" : "containsText",  
"store" : "yes", "index" : "analyzed" , "term\_vector" :  
"with\_positions\_offsets"}

* * *

curl -XGET [http://localhost:9200/myindex/program/\_search](http://localhost:9200/myindex/program/_search) -d '{  
"query" : {  
"query\_string" : {  
"query" : "ja",  
"fields" : ["autoCompleteContainsProgramTitle"],  
"default\_operator" : "or",  
"analyze\_wildcard" : false,  
"analyzer": "containsText"  
}  
},  
"fields" : ["autoCompleteContainsProgramTitle"]  
}'

----- response

"hits": [  
{  
"\_id": "1934155",  
"\_index": "myindex",  
"\_score": 6.411867,  
"\_type": "program",  
"fields": {  
"autoCompleteContainsProgramTitle": "J.A. Johnson"  
}  
},  
{  
"\_id": "16039073",  
"\_index": "myindex",  
"\_score": 5.1311817,  
"\_type": "program",  
"fields": {  
"autoCompleteContainsProgramTitle": "Sam ja  
Vjatskij urozhenec"  
}  
},  
{  
"\_id": "3904322",  
"\_index": "myindex",  
"\_score": 5.130897,  
"\_type": "program",  
"fields": {  
"autoCompleteContainsProgramTitle": "Ljudmila  
Chursina. Ja- Nich'ja"  
}  
},  
{  
"\_id": "1954834",  
"\_index": "myindex",  
"\_score": 4.4931150000000004,  
"\_type": "program",  
"fields": {  
"autoCompleteContainsProgramTitle": "J.A. Johnson/  
Eastern Star Baptist Church"  
}  
}  
]

* * *

curl -XGET [http://localhost:9200/myindex/program/\_search](http://localhost:9200/myindex/program/_search) -d '{  
"query" : {  
"term" : { "programID": "1652094" }  
}  
}'

----- response

{  
"\_shards": {  
"failed": 0,  
"successful": 4,  
"total": 4  
},  
"hits": {  
"hits": [  
{  
"\_id": "1652094",  
"\_index": "myindex",  
"\_score": 9.8563279999999995,  
"\_source": {  
"autoCompleteContainsProgramTitle": "627 Lb Woman  
Jackies Story",  
"programID": "1652094"  
},  
"\_type": "program"  
}  
],  
"max\_score": 9.8563279999999995,  
"total": 1  
},  
"timed\_out": false,  
"took": 2  
}

So if I run the same thing in solr using the following schema snippet  
I get all the results I would expect.

---

<div class="post-metadata">

**Author:** ![Neil1](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@Neil1](https://discuss.elastic.co/u/Neil1)\
**Post date:** [October 4, 2011, 7:33pm UTC](https://discuss.elastic.co/t/analysis-mismatch-in-elastic-search/5514/2 "2011-10-04T19:33:56Z")

</div>

I realized that I'm getting this error:

curl -XGET 'localhost:9200/myindex/\_analyze?analyzer=containsText' -d  
'627 Lb Woman Jackies Story'  
{"error":"ElasticSearchIllegalArgumentException[failed to find  
analyzer]","status":400}

So I'm confused as why elastic search would startup if this is broken.

Any ideas on why my yml isn't conveying the containsText analyzer?

Or how to troubleshoot?

Thanks,

Neil

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 4, 2011, 10:44pm UTC](https://discuss.elastic.co/t/analysis-mismatch-in-elastic-search/5514/3 "2011-10-04T22:44:56Z")

</div>

First, your analysis configuration is wrong. you are missing the top level  
index setting. See some samples here:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/).

Second, where did you get that mapping configuration? Thats not how you  
define mappings. See more here:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/) on mapping definition,  
and ways to define mappings include providing then in the create index API  
(recommended), using the put mapping API, or setting them in the config  
section.

On Tue, Oct 4, 2011 at 9:33 PM, Neil [neilmatthewlott@gmail.com](mailto:neilmatthewlott@gmail.com) wrote:

> I realized that I'm getting this error:
> 
> curl -XGET 'localhost:9200/myindex/\_analyze?analyzer=containsText' -d  
> '627 Lb Woman Jackies Story'  
> {"error":"ElasticSearchIllegalArgumentException[failed to find  
> analyzer]","status":400}
> 
> So I'm confused as why Elasticsearch would startup if this is broken.
> 
> Any ideas on why my yml isn't conveying the containsText analyzer?
> 
> Or how to troubleshoot?
> 
> Thanks,
> 
> Neil

---

<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:52am UTC](https://discuss.elastic.co/t/analysis-mismatch-in-elastic-search/5514/4 "2017-07-06T03:52:49Z")

</div>

Closed on July 6, 2017, 3:52am UTC


