# edgeNGram weirdness

**URL:** <https://discuss.elastic.co/t/edgengram-weirdness/9372>\
**Category:** Elasticsearch\
**Created:** [October 16, 2012, 8:39am UTC](https://discuss.elastic.co/t/edgengram-weirdness/9372 "2012-10-16T08:39:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Axsuul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axsuul/32/2663_2.png) [@Axsuul](https://discuss.elastic.co/u/Axsuul)\
**Post date:** [October 16, 2012, 8:39am UTC](https://discuss.elastic.co/t/edgengram-weirdness/9372/1 "2012-10-16T08:39:51Z")

</div>

Hi,

I'm having trouble getting a edgengram query to behave properly. I have one record "blue grass" with an edgengram minimum of 2. A query string of "blv" however returns "blue grass" although it shouldn't.

curl -X POST [http://localhost:9200/test](http://localhost:9200/test) -d '{  
"mappings": {  
"product/fragrance": {  
"properties": {  
"name\_query": {  
"index\_analyzer": "query\_index\_analyzer",  
"search\_anaylzer": "query\_search\_analyzer",  
"as": {},  
"type": "string"  
}  
}  
}  
},  
"settings": {  
"analysis": {  
"filter": {  
"query\_edgengram": {  
"type": "edgeNGram",  
"min\_gram": 2,  
"max\_gram": 20,  
"side": "front"  
}  
},  
"analyzer": {  
"query\_index\_analyzer": {  
"tokenizer": "lowercase",  
"filter": ["asciifolding", "query\_edgengram"]  
},  
"query\_search\_analyzer": {  
"tokenizer": "lowercase",  
"filter": ["asciifolding"]  
}  
}  
}  
}  
}'

curl -X POST "[http://localhost:9200/test/product%2Ffragrance/1](http://localhost:9200/test/product%2Ffragrance/1)" -d '{  
"name\_query": "blue grass"  
}'

curl -X GET "[http://localhost:9200/test/product%2Ffragrance/\_search?load=true&pretty=true](http://localhost:9200/test/product%2Ffragrance/_search?load=true&pretty=true)" -d '{  
"query": {  
"bool": {  
"must": [{  
"query\_string": {  
"query": "blv",  
"fields": ["name\_query"],  
"default\_operator": "OR"  
}  
}]  
}  
}  
}'

For some reason, I get a result from that. Can anyone explain why? Thanks. What I want to happen is "blv" shouldn't be returning "blue grass" although "bl" should. I've used the analyze API and see "blue grass" being broken down to "bl", "blu", "blue", "gr", "gra", "gras", "grass" but "blv" doesn't match any of those.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 16, 2012, 10:43am UTC](https://discuss.elastic.co/t/edgengram-weirdness/9372/2 "2012-10-16T10:43:00Z")

</div>

I answered on stackoverflow.

## [http://stackoverflow.com/questions/12909844/query-string-returning-results-not-found-in-edgengram/12911582#12911582](http://stackoverflow.com/questions/12909844/query-string-returning-results-not-found-in-edgengram/12911582#12911582)

David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 16 oct. 2012 à 10:39, Axsuul [axsuul@gmail.com](mailto:axsuul@gmail.com) a écrit :

> Hi,
> 
> I'm having trouble getting a edgengram query to behave properly. I have one  
> record "blue grass" with an edgengram minimum of 2. A query string of "blv"  
> however returns "blue grass" although it shouldn't.
> 
> curl -X POST [http://localhost:9200/test](http://localhost:9200/test) -d '{  
> "mappings": {  
> "product/fragrance": {  
> "properties": {  
> "name\_query": {  
> "index\_analyzer": "query\_index\_analyzer",  
> "search\_anaylzer": "query\_search\_analyzer",  
> "as": {},  
> "type": "string"  
> }  
> }  
> }  
> },  
> "settings": {  
> "analysis": {  
> "filter": {  
> "query\_edgengram": {  
> "type": "edgeNGram",  
> "min\_gram": 2,  
> "max\_gram": 20,  
> "side": "front"  
> }  
> },  
> "analyzer": {  
> "query\_index\_analyzer": {  
> "tokenizer": "lowercase",  
> "filter": ["asciifolding", "query\_edgengram"]  
> },  
> "query\_search\_analyzer": {  
> "tokenizer": "lowercase",  
> "filter": ["asciifolding"]  
> }  
> }  
> }  
> }  
> }'
> 
> curl -X POST "[http://localhost:9200/test/product%2Ffragrance/1](http://localhost:9200/test/product%2Ffragrance/1)" -d '{  
> "name\_query": "blue grass"  
> }'
> 
> curl -X GET  
> "[http://localhost:9200/test/product%2Ffragrance/\_search?load=true&pretty=true](http://localhost:9200/test/product%2Ffragrance/_search?load=true&pretty=true)"  
> -d '{  
> "query": {  
> "bool": {  
> "must": [{  
> "query\_string": {  
> "query": "blv",  
> "fields": ["name\_query"],  
> "default\_operator": "OR"  
> }  
> }]  
> }  
> }  
> }'
> 
> For some reason, I get a result from that. Can anyone explain why? Thanks.  
> What I want to happen is "blv" shouldn't be returning "blue grass" although  
> "bl" should. I've used the analyze API and see "blue grass" being broken  
> down to "bl", "blu", "blue", "gr", "gra", "gras", "grass" but "blv" doesn't  
> match any of those.
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/edgeNGram-weirdness-tp4024036.html](http://elasticsearch-users.115913.n3.nabble.com/edgeNGram-weirdness-tp4024036.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --

--

---

<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:08am UTC](https://discuss.elastic.co/t/edgengram-weirdness/9372/3 "2017-07-06T03:08:35Z")

</div>

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


