# Edge-Ngram returns irrelevant result

**URL:** <https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226>\
**Category:** Elasticsearch\
**Created:** [April 28, 2014, 8:50am UTC](https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226 "2014-04-28T08:50:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![cyrilforce](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@cyrilforce](https://discuss.elastic.co/u/cyrilforce)\
**Post date:** [April 28, 2014, 8:50am UTC](https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226/1 "2014-04-28T08:50:44Z")

</div>

Hi All,

I am trying to use \*edge-ngram filter \*to achieve auto-completion  
behaviour. However when i run the following query :

{  
"from" : "0",  
"size" : "20",  
"explain" : true,

```
"query" : {
*"multi_match": {*

```

- 

```
 "query": "happy",*

```

- 

```
 "fields": ["DISPLAY_NAME.NAME"]*

```

- 

```
}*

```

},  
"sort" : [{  
"\_score" : { "order" : "desc"}}]  
}

It returns me documents :

> <https://gist.github.com/cheehoo/11365794>

May i know how can i achieve the behaviour when i search "_happy_" then is  
should return me following result instead :

_1)Happy_  
_2)Happy birthday_  
_3)Happy valentine_

The analzyer configure :

"analysis" : {  
"analyzer" : {  
"edge\_ngram\_keyword\_lowercase\_analyzer" : {  
"tokenizer" : "keyword",  
"filter" : ["my\_edge\_ngram\_filter","lowercase"]  
}  
},  
"filter" : {  
"my\_edge\_ngram\_filter" : {  
"type" : "edgeNGram",  
"min\_gram" : "2",  
"max\_gram" : "30"

```
                }
            }

```

}

The mapping :

> <https://gist.github.com/cheehoo/11365917>

Thanks.

--  
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/e8a4446c-38c9-4c6b-8d2a-15374ef041a9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e8a4446c-38c9-4c6b-8d2a-15374ef041a9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [April 28, 2014, 9:23am UTC](https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226/2 "2014-04-28T09:23:09Z")

</div>

Hi,

I think your issue is that you are also applying the edge n-gram filter at  
search time. So "happy" is translated to ("ha" OR "hap" OR "happ" OR  
"happy"). You need to configure your mappings with a search analyzer[1]  
which is the same analyzer but without the edge-ngram filter (so just  
keyword and lowercase).

On a side note, you would benefit from putting the lowercase filter in  
front of your n-gram filter. This way, the lowercasing would be done only  
once.

[1]

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Mon, Apr 28, 2014 at 10:50 AM, cyrilforce [cheehoo84@gmail.com](mailto:cheehoo84@gmail.com) wrote:

> Hi All,
> 
> I am trying to use \*edge-ngram filter \*to achieve auto-completion  
> behaviour. However when i run the following query :
> 
> {  
> "from" : "0",  
> "size" : "20",  
> "explain" : true,
> 
> ```
> "query" : {
> *"multi_match": {*
> 
> ```
> 
> - 
> 
> ```
> "query": "happy",*
> 
> ```
> 
> - 
> 
> ```
> "fields": ["DISPLAY_NAME.NAME <http://DISPLAY_NAME.NAME>"]*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> },  
> "sort" : [{  
> "\_score" : { "order" : "desc"}}]  
> }
> 
> It returns me documents :
> 
> [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> 
> May i know how can i achieve the behaviour when i search "_happy_" then  
> is should return me following result instead :
> 
> _1)Happy_  
> _2)Happy birthday_  
> _3)Happy valentine_
> 
> The analzyer configure :
> 
> "analysis" : {  
> "analyzer" : {  
> "edge\_ngram\_keyword\_lowercase\_analyzer" : {  
> "tokenizer" : "keyword",  
> "filter" : ["my\_edge\_ngram\_filter","lowercase"]  
> }  
> },  
> "filter" : {  
> "my\_edge\_ngram\_filter" : {  
> "type" : "edgeNGram",  
> "min\_gram" : "2",  
> "max\_gram" : "30"
> 
> ```
> }
> }
> 
> ```
> 
> }
> 
> The mapping :  
> [irrevelent\_response\_ngram\_edge\_mapping.json · GitHub](https://gist.github.com/cheehoo/11365917)
> 
> Thanks.
> 
> --  
> 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/e8a4446c-38c9-4c6b-8d2a-15374ef041a9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e8a4446c-38c9-4c6b-8d2a-15374ef041a9%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/e8a4446c-38c9-4c6b-8d2a-15374ef041a9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/e8a4446c-38c9-4c6b-8d2a-15374ef041a9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
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/CAL6Z4j5iMm-e%3Dk-vf6\_Hw%3D7EDgNzoG%2BrQLfAW6-pJdw1JbJYYQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5iMm-e%3Dk-vf6_Hw%3D7EDgNzoG%2BrQLfAW6-pJdw1JbJYYQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![cyrilforce](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@cyrilforce](https://discuss.elastic.co/u/cyrilforce)\
**Post date:** [April 28, 2014, 10:29am UTC](https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226/3 "2014-04-28T10:29:55Z")

</div>

Hi Adrien,

But now when i type "_hap_" it doesn't return the following after i  
configure with search\_analzyer :

_1)Happy_  
_2)Happy birthday_  
_3)Happy valentine_

Sorry maybe i have missed the requirements at the first place. Basically i  
wanted to use the edge\_ngram to achieve auto-completion not full-text  
matching.

Thanks.

On Mon, Apr 28, 2014 at 5:23 PM, Adrien Grand \<  
[adrien.grand@elasticsearch.com](mailto:adrien.grand@elasticsearch.com)\> wrote:

> Hi,
> 
> I think your issue is that you are also applying the edge n-gram filter at  
> search time. So "happy" is translated to ("ha" OR "hap" OR "happ" OR  
> "happy"). You need to configure your mappings with a search analyzer[1]  
> which is the same analyzer but without the edge-ngram filter (so just  
> keyword and lowercase).
> 
> On a side note, you would benefit from putting the lowercase filter in  
> front of your n-gram filter. This way, the lowercasing would be done only  
> once.
> 
> [1]  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#string)
> 
> On Mon, Apr 28, 2014 at 10:50 AM, cyrilforce [cheehoo84@gmail.com](mailto:cheehoo84@gmail.com) wrote:
> 
> > Hi All,
> > 
> > I am trying to use \*edge-ngram filter \*to achieve auto-completion  
> > behaviour. However when i run the following query :
> > 
> > {  
> > "from" : "0",  
> > "size" : "20",  
> > "explain" : true,
> > 
> > ```
> > "query" : {
> > *"multi_match": {*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > "query": "happy",*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > "fields": ["DISPLAY_NAME.NAME <http://DISPLAY_NAME.NAME>"]*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > }*
> > 
> > ```
> > 
> > },  
> > "sort" : [{  
> > "\_score" : { "order" : "desc"}}]  
> > }
> > 
> > It returns me documents :
> > 
> > [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> > 
> > May i know how can i achieve the behaviour when i search "_happy_" then  
> > is should return me following result instead :
> > 
> > _1)Happy_  
> > _2)Happy birthday_  
> > _3)Happy valentine_
> > 
> > The analzyer configure :
> > 
> > "analysis" : {  
> > "analyzer" : {  
> > "edge\_ngram\_keyword\_lowercase\_analyzer" : {  
> > "tokenizer" : "keyword",  
> > "filter" : ["my\_edge\_ngram\_filter","lowercase"]  
> > }  
> > },  
> > "filter" : {  
> > "my\_edge\_ngram\_filter" : {  
> > "type" : "edgeNGram",  
> > "min\_gram" : "2",  
> > "max\_gram" : "30"
> > 
> > ```
> > }
> > }
> > 
> > ```
> > 
> > }
> > 
> > The mapping :  
> > [irrevelent\_response\_ngram\_edge\_mapping.json · GitHub](https://gist.github.com/cheehoo/11365917)
> > 
> > Thanks.
> > 
> > --  
> > 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/e8a4446c-38c9-4c6b-8d2a-15374ef041a9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e8a4446c-38c9-4c6b-8d2a-15374ef041a9%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/e8a4446c-38c9-4c6b-8d2a-15374ef041a9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/e8a4446c-38c9-4c6b-8d2a-15374ef041a9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Adrien Grand
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe](https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/CAL6Z4j5iMm-e%3Dk-vf6\_Hw%3D7EDgNzoG%2BrQLfAW6-pJdw1JbJYYQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5iMm-e%3Dk-vf6_Hw%3D7EDgNzoG%2BrQLfAW6-pJdw1JbJYYQ%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5iMm-e%3Dk-vf6\_Hw%3D7EDgNzoG%2BrQLfAW6-pJdw1JbJYYQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5iMm-e%3Dk-vf6_Hw%3D7EDgNzoG%2BrQLfAW6-pJdw1JbJYYQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Regards,

Chee Hoo

--  
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/CAGS0%2Bg-6noA3oFDQiGMQD1BdfxEK2w5rFpdXB9-iaeRie4ak%3DA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGS0%2Bg-6noA3oFDQiGMQD1BdfxEK2w5rFpdXB9-iaeRie4ak%3DA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [April 28, 2014, 11:36am UTC](https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226/4 "2014-04-28T11:36:01Z")

</div>

To return the query results in the order you want, execute the sort on a  
not\_analyzed version of the term, i.e

"DISPLAY\_NAME": {  
"type": "string",  
"fields": {  
"NAME": {  
"type": "string",  
"analyzer": "edge\_ngram\_keyword\_lowercase\_analyzer"  
},  
"untouched":{  
"type": "string",  
"analyzer":"not\_analyzed"  
}  
}  
}

Reindex the data. Now in your query you can sort on the 'untouched' field:

{  
"from" : "0",  
"size" : "20",  
"explain" : true,

```
"query" : {
"multi_match": {
     "query": "happy",
      "fields": ["DISPLAY_NAME.name"]
 }
},
"sort" : [{ 
  "DISPLAY_NAME.untouched" : { "order" : "desc"}}] 

```

}

which will return

_1)Happy_  
_2)Happy birthday_  
_3)Happy valentine_

Dan

On Monday, April 28, 2014 9:50:44 AM UTC+1, cyrilforce wrote:

> Hi All,
> 
> I am trying to use \*edge-ngram filter \*to achieve auto-completion  
> behaviour. However when i run the following query :
> 
> {  
> "from" : "0",  
> "size" : "20",  
> "explain" : true,
> 
> ```
> "query" : {
> *"multi_match": {*
> 
> ```
> 
> - 
> 
> ```
> "query": "happy",*
> 
> ```
> 
> - 
> 
> ```
> "fields": ["DISPLAY_NAME.NAME <http://DISPLAY_NAME.NAME>"]*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> },  
> "sort" : [{  
> "\_score" : { "order" : "desc"}}]  
> }
> 
> It returns me documents :
> 
> [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> 
> May i know how can i achieve the behaviour when i search "_happy_" then  
> is should return me following result instead :
> 
> _1)Happy_  
> _2)Happy birthday_  
> _3)Happy valentine_
> 
> The analzyer configure :
> 
> "analysis" : {  
> "analyzer" : {  
> "edge\_ngram\_keyword\_lowercase\_analyzer" : {  
> "tokenizer" : "keyword",  
> "filter" : ["my\_edge\_ngram\_filter","lowercase"]  
> }  
> },  
> "filter" : {  
> "my\_edge\_ngram\_filter" : {  
> "type" : "edgeNGram",  
> "min\_gram" : "2",  
> "max\_gram" : "30"
> 
> ```
> }
> }
> 
> ```
> 
> }
> 
> The mapping :  
> [irrevelent\_response\_ngram\_edge\_mapping.json · GitHub](https://gist.github.com/cheehoo/11365917)
> 
> Thanks.

--  
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/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![cyrilforce](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@cyrilforce](https://discuss.elastic.co/u/cyrilforce)\
**Post date:** [April 28, 2014, 11:41am UTC](https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226/5 "2014-04-28T11:41:38Z")

</div>

Hi dan

I tried this before however it returns me some irrelevant result as well :

> <https://gist.github.com/cheehoo/11365794>

How I could get only the relevant result with the sorting via edge ngram ?  
Thanks  
On Apr 28, 2014 7:36 PM, "Dan Tuffery" [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> To return the query results in the order you want, execute the sort on a  
> not\_analyzed version of the term, i.e
> 
> "DISPLAY\_NAME": {  
> "type": "string",  
> "fields": {  
> "NAME": {  
> "type": "string",  
> "analyzer": "edge\_ngram\_keyword\_lowercase\_analyzer"  
> },  
> "untouched":{  
> "type": "string",  
> "analyzer":"not\_analyzed"  
> }  
> }  
> }
> 
> Reindex the data. Now in your query you can sort on the 'untouched' field:
> 
> {  
> "from" : "0",  
> "size" : "20",  
> "explain" : true,
> 
> ```
> "query" : {
> "multi_match": {
> "query": "happy",
> "fields": ["DISPLAY_NAME.name"]
> }
> },
> "sort" : [{
> "DISPLAY_NAME.untouched" : { "order" : "desc"}}]
> 
> ```
> 
> }
> 
> which will return
> 
> _1)Happy_  
> _2)Happy birthday_  
> _3)Happy valentine_
> 
> Dan
> 
> On Monday, April 28, 2014 9:50:44 AM UTC+1, cyrilforce wrote:
> 
> > Hi All,
> > 
> > I am trying to use \*edge-ngram filter \*to achieve auto-completion  
> > behaviour. However when i run the following query :
> > 
> > {  
> > "from" : "0",  
> > "size" : "20",  
> > "explain" : true,
> > 
> > ```
> > "query" : {
> > *"multi_match": {*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > "query": "happy",*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > "fields": ["DISPLAY_NAME.NAME <http://DISPLAY_NAME.NAME>"]*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > }*
> > 
> > ```
> > 
> > },  
> > "sort" : [{  
> > "\_score" : { "order" : "desc"}}]  
> > }
> > 
> > It returns me documents :
> > 
> > [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> > 
> > May i know how can i achieve the behaviour when i search "_happy_" then  
> > is should return me following result instead :
> > 
> > _1)Happy_  
> > _2)Happy birthday_  
> > _3)Happy valentine_
> > 
> > The analzyer configure :
> > 
> > "analysis" : {  
> > "analyzer" : {  
> > "edge\_ngram\_keyword\_lowercase\_analyzer" : {  
> > "tokenizer" : "keyword",  
> > "filter" : ["my\_edge\_ngram\_filter","lowercase"]  
> > }  
> > },  
> > "filter" : {  
> > "my\_edge\_ngram\_filter" : {  
> > "type" : "edgeNGram",  
> > "min\_gram" : "2",  
> > "max\_gram" : "30"
> > 
> > ```
> > }
> > }
> > 
> > ```
> > 
> > }
> > 
> > The mapping :  
> > [irrevelent\_response\_ngram\_edge\_mapping.json · GitHub](https://gist.github.com/cheehoo/11365917)
> > 
> > Thanks.
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe](https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe).  
> > To unsubscribe from this group and all its topics, 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/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAGS0%2Bg-yN%3DBa5%2BUgCcSwz4hVeAbo8O0c2BV1Wod1zvsKb\_QzKg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGS0%2Bg-yN%3DBa5%2BUgCcSwz4hVeAbo8O0c2BV1Wod1zvsKb_QzKg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [April 28, 2014, 12:17pm UTC](https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226/6 "2014-04-28T12:17:16Z")

</div>

As Adrien said don't apply the edge n-gram filter at search time. When you  
tried it what does you mapping look like, because "hap" should return a  
result.

Dan

On Monday, April 28, 2014 12:41:38 PM UTC+1, cyrilforce wrote:

> Hi dan
> 
> I tried this before however it returns me some irrelevant result as well :  
> [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> 
> How I could get only the relevant result with the sorting via edge ngram ?  
> Thanks  
> On Apr 28, 2014 7:36 PM, "Dan Tuffery" \<[dan.t...@gmail.com](mailto:dan.t...@gmail.com) \<javascript:\>\>  
> wrote:
> 
> > To return the query results in the order you want, execute the sort on a  
> > not\_analyzed version of the term, i.e
> > 
> > "DISPLAY\_NAME": {  
> > "type": "string",  
> > "fields": {  
> > "NAME": {  
> > "type": "string",  
> > "analyzer": "edge\_ngram\_keyword\_lowercase\_analyzer"  
> > },  
> > "untouched":{  
> > "type": "string",  
> > "analyzer":"not\_analyzed"  
> > }  
> > }  
> > }
> > 
> > Reindex the data. Now in your query you can sort on the 'untouched' field:
> > 
> > {  
> > "from" : "0",  
> > "size" : "20",  
> > "explain" : true,
> > 
> > ```
> > "query" : {
> > "multi_match": {
> > "query": "happy",
> > "fields": ["DISPLAY_NAME.name"]
> > }
> > },
> > "sort" : [{ 
> > "DISPLAY_NAME.untouched" : { "order" : "desc"}}] 
> > 
> > ```
> > 
> > }
> > 
> > which will return
> > 
> > _1)Happy_  
> > _2)Happy birthday_  
> > _3)Happy valentine_
> > 
> > Dan
> > 
> > On Monday, April 28, 2014 9:50:44 AM UTC+1, cyrilforce wrote:
> > 
> > > Hi All,
> > > 
> > > I am trying to use \*edge-ngram filter \*to achieve auto-completion  
> > > behaviour. However when i run the following query :
> > > 
> > > {  
> > > "from" : "0",  
> > > "size" : "20",  
> > > "explain" : true,
> > > 
> > > ```
> > > "query" : {
> > > *"multi_match": {*
> > > 
> > > ```
> > > 
> > > - 
> > > 
> > > ```
> > > "query": "happy",*
> > > 
> > > ```
> > > 
> > > - 
> > > 
> > > ```
> > > "fields": ["DISPLAY_NAME.NAME <http://DISPLAY_NAME.NAME>"]*
> > > 
> > > ```
> > > 
> > > - 
> > > 
> > > ```
> > > }*
> > > 
> > > ```
> > > 
> > > },  
> > > "sort" : [{  
> > > "\_score" : { "order" : "desc"}}]  
> > > }
> > > 
> > > It returns me documents :
> > > 
> > > [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> > > 
> > > May i know how can i achieve the behaviour when i search "_happy_" then  
> > > is should return me following result instead :
> > > 
> > > _1)Happy_  
> > > _2)Happy birthday_  
> > > _3)Happy valentine_
> > > 
> > > The analzyer configure :
> > > 
> > > "analysis" : {  
> > > "analyzer" : {  
> > > "edge\_ngram\_keyword\_lowercase\_analyzer" : {  
> > > "tokenizer" : "keyword",  
> > > "filter" : ["my\_edge\_ngram\_filter","lowercase"]  
> > > }  
> > > },  
> > > "filter" : {  
> > > "my\_edge\_ngram\_filter" : {  
> > > "type" : "edgeNGram",  
> > > "min\_gram" : "2",  
> > > "max\_gram" : "30"
> > > 
> > > ```
> > > }
> > > }
> > > 
> > > ```
> > > 
> > > }
> > > 
> > > The mapping :  
> > > [irrevelent\_response\_ngram\_edge\_mapping.json · GitHub](https://gist.github.com/cheehoo/11365917)
> > > 
> > > Thanks.
> > > 
> > > --  
> > > You received this message because you are subscribed to a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe](https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe).  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![cyrilforce](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@cyrilforce](https://discuss.elastic.co/u/cyrilforce)\
**Post date:** [April 28, 2014, 1:31pm UTC](https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226/7 "2014-04-28T13:31:24Z")

</div>

Hi Dan,

Not sure whether i have same understanding "_edge n-gram filter at search  
time_" refer to apply edge n-gram filter in the query ? If this is the case  
i think i didn't apply any analyzer in the query :

\*Here my query : \*

{  
"query" : {  
"multi\_match": {  
"query": "happy",  
"fields": ["DISPLAY\_NAME.AUTOCOMPLETE"]  
}  
},  
"sort" : [{  
"\_score" : { "order" : "desc"},  
"DISPLAY\_NAME.NAME" : { "order" : "asc" }}]  
}

\*The result : \*

> <https://gist.github.com/cheehoo/11371837>

As you notice in the result it returned :

Happenings  
Happier?

which aren't part of what i searched for.

\*The mapping : \*

> <https://gist.github.com/cheehoo/11371897>

\*The index : \*  
{  
"jdbc\_dev": {  
"settings": {  
"index.number\_of\_shards": "5",  
"index.number\_of\_replicas": "1",  
"index.version.created": "900299",  
"index.analysis.filter.my\_edge\_ngram\_filter.type": "edgeNGram",

"index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_analyzer.filter.1":  
"lowercase",

"index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_analyzer.filter.0":  
"my\_edge\_ngram\_filter",

"index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_analyzer.tokenizer":  
"keyword",  
"index.analysis.filter.my\_edge\_ngram\_filter.min\_gram": "2",  
"index.analysis.filter.my\_edge\_ngram\_filter.max\_gram": "30"  
}  
}  
}

After that with Adrien suggestion i tried create the analyzer

"analysis" : {  
"analyzer" : {  
"keyword\_lowercase\_analyzer" : {  
"tokenizer" : "keyword",  
"filter" : ["lowercase"]  
}  
}  
}

and recreate the mapping with :

"DISPLAY\_NAME": {  
"type": "string",  
"search\_analyzer" : "keyword\_lowercase\_analyzer"

}

however with this configuration it wasn't able to search via "hap" to  
return the following result :

_1)Happy_  
_2)Happy birthday_  
_3)Happy valentine_

Thanks

On Mon, Apr 28, 2014 at 8:17 PM, Dan Tuffery [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> As Adrien said don't apply the edge n-gram filter at search time. When you  
> tried it what does you mapping look like, because "hap" should return a  
> result.
> 
> Dan
> 
> On Monday, April 28, 2014 12:41:38 PM UTC+1, cyrilforce wrote:
> 
> > Hi dan
> > 
> > I tried this before however it returns me some irrelevant result as well :  
> > [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> > 
> > How I could get only the relevant result with the sorting via edge ngram  
> > ? Thanks  
> > On Apr 28, 2014 7:36 PM, "Dan Tuffery" [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > 
> > > To return the query results in the order you want, execute the sort on a  
> > > not\_analyzed version of the term, i.e
> > > 
> > > "DISPLAY\_NAME": {  
> > > "type": "string",  
> > > "fields": {  
> > > "NAME": {  
> > > "type": "string",  
> > > "analyzer": "edge\_ngram\_keyword\_lowercase\_analyzer"  
> > > },  
> > > "untouched":{  
> > > "type": "string",  
> > > "analyzer":"not\_analyzed"  
> > > }  
> > > }  
> > > }
> > > 
> > > Reindex the data. Now in your query you can sort on the 'untouched'  
> > > field:
> > > 
> > > {  
> > > "from" : "0",  
> > > "size" : "20",  
> > > "explain" : true,
> > > 
> > > ```
> > > "query" : {
> > > "multi_match": {
> > > "query": "happy",
> > > "fields": ["DISPLAY_NAME.name"]
> > > }
> > > },
> > > "sort" : [{
> > > "DISPLAY_NAME.untouched" : { "order" : "desc"}}]
> > > 
> > > ```
> > > 
> > > }
> > > 
> > > which will return
> > > 
> > > _1)Happy_  
> > > _2)Happy birthday_  
> > > _3)Happy valentine_
> > > 
> > > Dan
> > > 
> > > On Monday, April 28, 2014 9:50:44 AM UTC+1, cyrilforce wrote:
> > > 
> > > > Hi All,
> > > > 
> > > > I am trying to use \*edge-ngram filter \*to achieve auto-completion  
> > > > behaviour. However when i run the following query :
> > > > 
> > > > {  
> > > > "from" : "0",  
> > > > "size" : "20",  
> > > > "explain" : true,
> > > > 
> > > > ```
> > > > "query" : {
> > > > *"multi_match": {*
> > > > 
> > > > ```
> > > > 
> > > > - 
> > > > 
> > > > ```
> > > > "query": "happy",*
> > > > 
> > > > ```
> > > > 
> > > > - 
> > > > 
> > > > ```
> > > > "fields": ["DISPLAY_NAME.NAME <http://DISPLAY_NAME.NAME>"]*
> > > > 
> > > > ```
> > > > 
> > > > - 
> > > > 
> > > > ```
> > > > }*
> > > > 
> > > > ```
> > > > 
> > > > },  
> > > > "sort" : [{  
> > > > "\_score" : { "order" : "desc"}}]  
> > > > }
> > > > 
> > > > It returns me documents :
> > > > 
> > > > [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> > > > 
> > > > May i know how can i achieve the behaviour when i search "_happy_"  
> > > > then is should return me following result instead :
> > > > 
> > > > _1)Happy_  
> > > > _2)Happy birthday_  
> > > > _3)Happy valentine_
> > > > 
> > > > The analzyer configure :
> > > > 
> > > > "analysis" : {  
> > > > "analyzer" : {  
> > > > "edge\_ngram\_keyword\_lowercase\_analyzer" : {  
> > > > "tokenizer" : "keyword",  
> > > > "filter" : ["my\_edge\_ngram\_filter","lowercase"]  
> > > > }  
> > > > },  
> > > > "filter" : {  
> > > > "my\_edge\_ngram\_filter" : {  
> > > > "type" : "edgeNGram",  
> > > > "min\_gram" : "2",  
> > > > "max\_gram" : "30"
> > > > 
> > > > ```
> > > > }
> > > > }
> > > > 
> > > > ```
> > > > 
> > > > }
> > > > 
> > > > The mapping :  
> > > > [irrevelent\_response\_ngram\_edge\_mapping.json · GitHub](https://gist.github.com/cheehoo/11365917)
> > > > 
> > > > Thanks.
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to a topic in the  
> > > > Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > topic/elasticsearch/fhsCgFBF76E/unsubscribe.  
> > > > To unsubscribe from this group and all its topics, send an email to  
> > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > 
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%  
> > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe](https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe).  
> > To unsubscribe from this group and all its topics, 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/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Regards,

Chee Hoo

--  
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/CAGS0%2Bg95SAL--gSTfUm6gJRYq2pEeDgQiVqH%3DcoV%2BffLSn56tg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGS0%2Bg95SAL--gSTfUm6gJRYq2pEeDgQiVqH%3DcoV%2BffLSn56tg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [April 28, 2014, 1:43pm UTC](https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226/8 "2014-04-28T13:43:07Z")

</div>

Change your mapping to:

DISPLAY\_NAME": {  
"type": "multi\_field",  
"fields": {  
"AUTOCOMPLETE": {  
"type": "string",  
"index\_analyzer":  
"edge\_ngram\_keyword\_lowercase\_analyzer",  
"include\_in\_all": false  
},  
"NAME": {  
"type": "string",  
"analyzer": "standard",  
"include\_in\_all": false  
}  
}  
}

the DISPLAY\_NAME term will be indexed using  
'edge\_ngram\_keyword\_lowercase\_analyzer'. When you search on DISPLAY\_NAME

On Monday, April 28, 2014 2:31:24 PM UTC+1, cyrilforce wrote:

> Hi Dan,
> 
> Not sure whether i have same understanding "_edge n-gram filter at search  
> time_" refer to apply edge n-gram filter in the query ? If this is the  
> case i think i didn't apply any analyzer in the query :
> 
> \*Here my query : \*
> 
> {  
> "query" : {  
> "multi\_match": {  
> "query": "happy",  
> "fields": ["DISPLAY\_NAME.AUTOCOMPLETE"]  
> }  
> },  
> "sort" : [{  
> "\_score" : { "order" : "desc"},  
> "DISPLAY\_NAME.NAME" : { "order" : "asc" }}]  
> }
> 
> \*The result : \*  
> [edge\_ngram\_original.json · GitHub](https://gist.github.com/cheehoo/11371837)
> 
> As you notice in the result it returned :
> 
> Happenings  
> Happier?
> 
> which aren't part of what i searched for.
> 
> \*The mapping : \*  
> [edge\_ngram\_mapping\_original.json · GitHub](https://gist.github.com/cheehoo/11371897)
> 
> \*The index : \*  
> {  
> "jdbc\_dev": {  
> "settings": {  
> "index.number\_of\_shards": "5",  
> "index.number\_of\_replicas": "1",  
> "index.version.created": "900299",  
> "index.analysis.filter.my\_edge\_ngram\_filter.type": "edgeNGram",
> 
> "index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_analyzer.filter.1":  
> "lowercase",
> 
> "index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_analyzer.filter.0":  
> "my\_edge\_ngram\_filter",
> 
> "index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_analyzer.tokenizer":  
> "keyword",  
> "index.analysis.filter.my\_edge\_ngram\_filter.min\_gram": "2",  
> "index.analysis.filter.my\_edge\_ngram\_filter.max\_gram": "30"  
> }  
> }  
> }
> 
> After that with Adrien suggestion i tried create the analyzer
> 
> "analysis" : {  
> "analyzer" : {  
> "keyword\_lowercase\_analyzer" : {  
> "tokenizer" : "keyword",  
> "filter" : ["lowercase"]  
> }  
> }  
> }
> 
> and recreate the mapping with :
> 
> "DISPLAY\_NAME": {
> 
> ```
> "type": "string",
> "search_analyzer" : "keyword_lowercase_analyzer"
> 
> ```
> 
> }
> 
> however with this configuration it wasn't able to search via "hap" to  
> return the following result :
> 
> _1)Happy_  
> _2)Happy birthday_  
> _3)Happy valentine_
> 
> Thanks
> 
> On Mon, Apr 28, 2014 at 8:17 PM, Dan Tuffery \<[dan.t...@gmail.com](mailto:dan.t...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > As Adrien said don't apply the edge n-gram filter at search time. When  
> > you tried it what does you mapping look like, because "hap" should return a  
> > result.
> > 
> > Dan
> > 
> > On Monday, April 28, 2014 12:41:38 PM UTC+1, cyrilforce wrote:
> > 
> > > Hi dan
> > > 
> > > I tried this before however it returns me some irrelevant result as well  
> > > :  
> > > [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> > > 
> > > How I could get only the relevant result with the sorting via edge ngram  
> > > ? Thanks  
> > > On Apr 28, 2014 7:36 PM, "Dan Tuffery" [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > 
> > > > To return the query results in the order you want, execute the sort  
> > > > on a not\_analyzed version of the term, i.e
> > > > 
> > > > "DISPLAY\_NAME": {  
> > > > "type": "string",  
> > > > "fields": {  
> > > > "NAME": {  
> > > > "type": "string",  
> > > > "analyzer": "edge\_ngram\_keyword\_lowercase\_analyzer"  
> > > > },  
> > > > "untouched":{  
> > > > "type": "string",  
> > > > "analyzer":"not\_analyzed"  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > Reindex the data. Now in your query you can sort on the 'untouched'  
> > > > field:
> > > > 
> > > > {  
> > > > "from" : "0",  
> > > > "size" : "20",  
> > > > "explain" : true,
> > > > 
> > > > ```
> > > > "query" : {
> > > > "multi_match": {
> > > > "query": "happy",
> > > > "fields": ["DISPLAY_NAME.name"]
> > > > }
> > > > },
> > > > "sort" : [{ 
> > > > "DISPLAY_NAME.untouched" : { "order" : "desc"}}] 
> > > > 
> > > > ```
> > > > 
> > > > }
> > > > 
> > > > which will return
> > > > 
> > > > _1)Happy_  
> > > > _2)Happy birthday_  
> > > > _3)Happy valentine_
> > > > 
> > > > Dan
> > > > 
> > > > On Monday, April 28, 2014 9:50:44 AM UTC+1, cyrilforce wrote:
> > > > 
> > > > > Hi All,
> > > > > 
> > > > > I am trying to use \*edge-ngram filter \*to achieve auto-completion  
> > > > > behaviour. However when i run the following query :
> > > > > 
> > > > > {  
> > > > > "from" : "0",  
> > > > > "size" : "20",  
> > > > > "explain" : true,
> > > > > 
> > > > > ```
> > > > > "query" : {
> > > > > *"multi_match": {*
> > > > > 
> > > > > ```
> > > > > 
> > > > > - 
> > > > > 
> > > > > ```
> > > > > "query": "happy",*
> > > > > 
> > > > > ```
> > > > > 
> > > > > - 
> > > > > 
> > > > > ```
> > > > > "fields": ["DISPLAY_NAME.NAME <http://DISPLAY_NAME.NAME>"]*
> > > > > 
> > > > > ```
> > > > > 
> > > > > - 
> > > > > 
> > > > > ```
> > > > > }*
> > > > > 
> > > > > ```
> > > > > 
> > > > > },  
> > > > > "sort" : [{  
> > > > > "\_score" : { "order" : "desc"}}]  
> > > > > }
> > > > > 
> > > > > It returns me documents :
> > > > > 
> > > > > [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> > > > > 
> > > > > May i know how can i achieve the behaviour when i search "_happy_"  
> > > > > then is should return me following result instead :
> > > > > 
> > > > > _1)Happy_  
> > > > > _2)Happy birthday_  
> > > > > _3)Happy valentine_
> > > > > 
> > > > > The analzyer configure :
> > > > > 
> > > > > "analysis" : {  
> > > > > "analyzer" : {  
> > > > > "edge\_ngram\_keyword\_lowercase\_analyzer" : {  
> > > > > "tokenizer" : "keyword",  
> > > > > "filter" : ["my\_edge\_ngram\_filter","lowercase"]  
> > > > > }  
> > > > > },  
> > > > > "filter" : {  
> > > > > "my\_edge\_ngram\_filter" : {  
> > > > > "type" : "edgeNGram",  
> > > > > "min\_gram" : "2",  
> > > > > "max\_gram" : "30"
> > > > > 
> > > > > ```
> > > > > }
> > > > > }
> > > > > 
> > > > > ```
> > > > > 
> > > > > }
> > > > > 
> > > > > The mapping :  
> > > > > [irrevelent\_response\_ngram\_edge\_mapping.json · GitHub](https://gist.github.com/cheehoo/11365917)
> > > > > 
> > > > > Thanks.
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to a topic in the  
> > > > > Google Groups "elasticsearch" group.  
> > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > topic/elasticsearch/fhsCgFBF76E/unsubscribe.  
> > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > > 
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%  
> > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .  
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe](https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe).  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Regards,
> 
> Chee Hoo

--  
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/f296c0d1-0248-4d62-aba4-057373596343%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f296c0d1-0248-4d62-aba4-057373596343%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![cyrilforce](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@cyrilforce](https://discuss.elastic.co/u/cyrilforce)\
**Post date:** [April 28, 2014, 2:08pm UTC](https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226/9 "2014-04-28T14:08:24Z")

</div>

Hi Dan,

It worked ! Btw one more questions. Now the result returned me the same  
scores for all :

1)"\_score": 1.6931472,  
"\_source": {  
"DISPLAY\_NAME": "Happy Tears",

1. "\_score": 1.6931472,  
"\_source": {  
"DISPLAY\_NAME": "Happy Happy Sangeethalu",

3)"\_score": 1.6931472,  
"\_source": {  
"DISPLAY\_NAME": "Happy",

Anyway to manipulate the 3) to appear first ?

\*The query : \*

{  
"explain" : true,  
"query" : {  
"multi\_match": {  
"query": "happy",  
"fields": ["DISPLAY\_NAME.AUTOCOMPLETE"]  
}  
},  
"sort" : [{  
"\_score" : { "order" : "desc"},  
"DISPLAY\_NAME.NAME" : { "order" : "asc" }}]  
}

Thanks.

On Mon, Apr 28, 2014 at 9:43 PM, Dan Tuffery [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> Change your mapping to:
> 
> DISPLAY\_NAME": {  
> "type": "multi\_field",  
> "fields": {  
> "AUTOCOMPLETE": {  
> "type": "string",  
> "index\_analyzer":  
> "edge\_ngram\_keyword\_lowercase\_analyzer",  
> "include\_in\_all": false  
> },  
> "NAME": {  
> "type": "string",  
> "analyzer": "standard",  
> "include\_in\_all": false  
> }  
> }  
> }
> 
> the DISPLAY\_NAME term will be indexed using  
> 'edge\_ngram\_keyword\_lowercase\_analyzer'. When you search on DISPLAY\_NAME
> 
> On Monday, April 28, 2014 2:31:24 PM UTC+1, cyrilforce wrote:
> 
> > Hi Dan,
> > 
> > Not sure whether i have same understanding "_edge n-gram filter at  
> > search time_" refer to apply edge n-gram filter in the query ? If this  
> > is the case i think i didn't apply any analyzer in the query :
> > 
> > \*Here my query : \*
> > 
> > {  
> > "query" : {  
> > "multi\_match": {  
> > "query": "happy",  
> > "fields": ["DISPLAY\_NAME.AUTOCOMPLETE"]  
> > }  
> > },  
> > "sort" : [{  
> > "\_score" : { "order" : "desc"},  
> > "DISPLAY\_NAME.NAME" : { "order" : "asc" }}]  
> > }
> > 
> > \*The result : \*  
> > [edge\_ngram\_original.json · GitHub](https://gist.github.com/cheehoo/11371837)
> > 
> > As you notice in the result it returned :
> > 
> > Happenings  
> > Happier?
> > 
> > which aren't part of what i searched for.
> > 
> > \*The mapping : \*  
> > [edge\_ngram\_mapping\_original.json · GitHub](https://gist.github.com/cheehoo/11371897)
> > 
> > \*The index : \*  
> > {  
> > "jdbc\_dev": {  
> > "settings": {  
> > "index.number\_of\_shards": "5",  
> > "index.number\_of\_replicas": "1",  
> > "index.version.created": "900299",  
> > "index.analysis.filter.my\_edge\_ngram\_filter.type":  
> > "edgeNGram",  
> > "index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_analyzer.filter.1":  
> > "lowercase",  
> > "index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_analyzer.filter.0":  
> > "my\_edge\_ngram\_filter",  
> > "index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_analyzer.tokenizer":  
> > "keyword",  
> > "index.analysis.filter.my\_edge\_ngram\_filter.min\_gram": "2",  
> > "index.analysis.filter.my\_edge\_ngram\_filter.max\_gram": "30"  
> > }  
> > }  
> > }
> > 
> > After that with Adrien suggestion i tried create the analyzer
> > 
> > "analysis" : {  
> > "analyzer" : {  
> > "keyword\_lowercase\_analyzer" : {  
> > "tokenizer" : "keyword",  
> > "filter" : ["lowercase"]  
> > }  
> > }  
> > }
> > 
> > and recreate the mapping with :
> > 
> > "DISPLAY\_NAME": {
> > 
> > ```
> > "type": "string",
> > "search_analyzer" : "keyword_lowercase_analyzer"
> > 
> > ```
> > 
> > }
> > 
> > however with this configuration it wasn't able to search via "hap" to  
> > return the following result :
> > 
> > _1)Happy_  
> > _2)Happy birthday_  
> > _3)Happy valentine_
> > 
> > Thanks
> > 
> > On Mon, Apr 28, 2014 at 8:17 PM, Dan Tuffery [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > 
> > > As Adrien said don't apply the edge n-gram filter at search time. When  
> > > you tried it what does you mapping look like, because "hap" should return a  
> > > result.
> > > 
> > > Dan
> > > 
> > > On Monday, April 28, 2014 12:41:38 PM UTC+1, cyrilforce wrote:
> > > 
> > > > Hi dan
> > > > 
> > > > I tried this before however it returns me some irrelevant result as  
> > > > well :  
> > > > [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> > > > 
> > > > How I could get only the relevant result with the sorting via edge  
> > > > ngram ? Thanks  
> > > > On Apr 28, 2014 7:36 PM, "Dan Tuffery" [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > 
> > > > > To return the query results in the order you want, execute the sort  
> > > > > on a not\_analyzed version of the term, i.e
> > > > > 
> > > > > "DISPLAY\_NAME": {  
> > > > > "type": "string",  
> > > > > "fields": {  
> > > > > "NAME": {  
> > > > > "type": "string",  
> > > > > "analyzer": "edge\_ngram\_keyword\_lowercase\_analyzer"  
> > > > > },  
> > > > > "untouched":{  
> > > > > "type": "string",  
> > > > > "analyzer":"not\_analyzed"  
> > > > > }  
> > > > > }  
> > > > > }
> > > > > 
> > > > > Reindex the data. Now in your query you can sort on the 'untouched'  
> > > > > field:
> > > > > 
> > > > > {  
> > > > > "from" : "0",  
> > > > > "size" : "20",  
> > > > > "explain" : true,
> > > > > 
> > > > > ```
> > > > > "query" : {
> > > > > "multi_match": {
> > > > > "query": "happy",
> > > > > "fields": ["DISPLAY_NAME.name"]
> > > > > }
> > > > > },
> > > > > "sort" : [{
> > > > > "DISPLAY_NAME.untouched" : { "order" : "desc"}}]
> > > > > 
> > > > > ```
> > > > > 
> > > > > }
> > > > > 
> > > > > which will return
> > > > > 
> > > > > _1)Happy_  
> > > > > _2)Happy birthday_  
> > > > > _3)Happy valentine_
> > > > > 
> > > > > Dan
> > > > > 
> > > > > On Monday, April 28, 2014 9:50:44 AM UTC+1, cyrilforce wrote:
> > > > > 
> > > > > > Hi All,
> > > > > > 
> > > > > > I am trying to use \*edge-ngram filter \*to achieve auto-completion  
> > > > > > behaviour. However when i run the following query :
> > > > > > 
> > > > > > {  
> > > > > > "from" : "0",  
> > > > > > "size" : "20",  
> > > > > > "explain" : true,
> > > > > > 
> > > > > > ```
> > > > > > "query" : {
> > > > > > *"multi_match": {*
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > - 
> > > > > > 
> > > > > > ```
> > > > > > "query": "happy",*
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > - 
> > > > > > 
> > > > > > ```
> > > > > > "fields": ["DISPLAY_NAME.NAME <http://DISPLAY_NAME.NAME>"]*
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > - 
> > > > > > 
> > > > > > ```
> > > > > > }*
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > },  
> > > > > > "sort" : [{  
> > > > > > "\_score" : { "order" : "desc"}}]  
> > > > > > }
> > > > > > 
> > > > > > It returns me documents :
> > > > > > 
> > > > > > [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> > > > > > 
> > > > > > May i know how can i achieve the behaviour when i search "_happy_"  
> > > > > > then is should return me following result instead :
> > > > > > 
> > > > > > _1)Happy_  
> > > > > > _2)Happy birthday_  
> > > > > > _3)Happy valentine_
> > > > > > 
> > > > > > The analzyer configure :
> > > > > > 
> > > > > > "analysis" : {  
> > > > > > "analyzer" : {  
> > > > > > "edge\_ngram\_keyword\_lowercase\_analyzer" : {  
> > > > > > "tokenizer" : "keyword",  
> > > > > > "filter" : ["my\_edge\_ngram\_filter","lowercase"]  
> > > > > > }  
> > > > > > },  
> > > > > > "filter" : {  
> > > > > > "my\_edge\_ngram\_filter" : {  
> > > > > > "type" : "edgeNGram",  
> > > > > > "min\_gram" : "2",  
> > > > > > "max\_gram" : "30"
> > > > > > 
> > > > > > ```
> > > > > > }
> > > > > > }
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > }
> > > > > > 
> > > > > > The mapping :  
> > > > > > [irrevelent\_response\_ngram\_edge\_mapping.json · GitHub](https://gist.github.com/cheehoo/11365917)
> > > > > > 
> > > > > > Thanks.
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to a topic in the  
> > > > > > Google Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/to](https://groups.google.com/d/to)  
> > > > > > pic/elasticsearch/fhsCgFBF76E/unsubscribe.  
> > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > > > 
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40goo  
> > > > > [glegroups.com](http://glegroups.com)[https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > .  
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to a topic in the  
> > > > Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > topic/elasticsearch/fhsCgFBF76E/unsubscribe.  
> > > > To unsubscribe from this group and all its topics, send an email to  
> > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%  
> > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > Regards,
> > 
> > Chee Hoo
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe](https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/f296c0d1-0248-4d62-aba4-057373596343%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f296c0d1-0248-4d62-aba4-057373596343%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f296c0d1-0248-4d62-aba4-057373596343%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f296c0d1-0248-4d62-aba4-057373596343%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Regards,

Chee Hoo

--  
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/CAGS0%2Bg-Hc1PSLqQpd%2Bs2d9hzQ0b2MREUtXWoFh\_-%3DqjtqNYmOA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGS0%2Bg-Hc1PSLqQpd%2Bs2d9hzQ0b2MREUtXWoFh_-%3DqjtqNYmOA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [April 28, 2014, 6:03pm UTC](https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226/10 "2014-04-28T18:03:53Z")

</div>

You could use a function score query and use the field length as the score:

{  
"from": "0",  
"size": "20",  
"explain": true,  
"query": {  
"function\_score": {  
"query": {  
"multi\_match": {  
"query": "happy",  
"fields": [  
"DISPLAY\_NAME.name"  
]  
}  
},  
"script\_score": {  
"script": "\_score =  
pow(doc['DISPLAY\_NAME.untouched'].value.length(), -1)"  
}  
}  
}  
}

Dan

On Monday, April 28, 2014 3:08:24 PM UTC+1, cyrilforce wrote:

> Hi Dan,
> 
> It worked ! Btw one more questions. Now the result returned me the same  
> scores for all :
> 
> 1)"\_score": 1.6931472,  
> "\_source": {  
> "DISPLAY\_NAME": "Happy Tears",
> 
> 1. "\_score": 1.6931472,  
> "\_source": {  
> "DISPLAY\_NAME": "Happy Happy Sangeethalu",
> 
> 3)"\_score": 1.6931472,  
> "\_source": {  
> "DISPLAY\_NAME": "Happy",
> 
> Anyway to manipulate the 3) to appear first ?
> 
> \*The query : \*
> 
> {  
> "explain" : true,  
> "query" : {  
> "multi\_match": {  
> "query": "happy",  
> "fields": ["DISPLAY\_NAME.AUTOCOMPLETE"]  
> }  
> },  
> "sort" : [{  
> "\_score" : { "order" : "desc"},  
> "DISPLAY\_NAME.NAME" : { "order" : "asc" }}]  
> }
> 
> Thanks.
> 
> On Mon, Apr 28, 2014 at 9:43 PM, Dan Tuffery \<[dan.t...@gmail.com](mailto:dan.t...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Change your mapping to:
> > 
> > DISPLAY\_NAME": {  
> > "type": "multi\_field",  
> > "fields": {  
> > "AUTOCOMPLETE": {  
> > "type": "string",  
> > "index\_analyzer":  
> > "edge\_ngram\_keyword\_lowercase\_analyzer",  
> > "include\_in\_all": false  
> > },  
> > "NAME": {  
> > "type": "string",  
> > "analyzer": "standard",  
> > "include\_in\_all": false  
> > }  
> > }  
> > }
> > 
> > the DISPLAY\_NAME term will be indexed using  
> > 'edge\_ngram\_keyword\_lowercase\_analyzer'. When you search on DISPLAY\_NAME
> > 
> > On Monday, April 28, 2014 2:31:24 PM UTC+1, cyrilforce wrote:
> > 
> > > Hi Dan,
> > > 
> > > Not sure whether i have same understanding "_edge n-gram filter at  
> > > search time_" refer to apply edge n-gram filter in the query ? If this  
> > > is the case i think i didn't apply any analyzer in the query :
> > > 
> > > \*Here my query : \*
> > > 
> > > {  
> > > "query" : {  
> > > "multi\_match": {  
> > > "query": "happy",  
> > > "fields": ["DISPLAY\_NAME.AUTOCOMPLETE"]  
> > > }  
> > > },  
> > > "sort" : [{  
> > > "\_score" : { "order" : "desc"},  
> > > "DISPLAY\_NAME.NAME" : { "order" : "asc" }}]  
> > > }
> > > 
> > > \*The result : \*  
> > > [edge\_ngram\_original.json · GitHub](https://gist.github.com/cheehoo/11371837)
> > > 
> > > As you notice in the result it returned :
> > > 
> > > Happenings  
> > > Happier?
> > > 
> > > which aren't part of what i searched for.
> > > 
> > > \*The mapping : \*  
> > > [edge\_ngram\_mapping\_original.json · GitHub](https://gist.github.com/cheehoo/11371897)
> > > 
> > > \*The index : \*  
> > > {  
> > > "jdbc\_dev": {  
> > > "settings": {  
> > > "index.number\_of\_shards": "5",  
> > > "index.number\_of\_replicas": "1",  
> > > "index.version.created": "900299",  
> > > "index.analysis.filter.my\_edge\_ngram\_filter.type":  
> > > "edgeNGram",  
> > > "index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_analyzer.filter.1":  
> > > "lowercase",  
> > > "index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_analyzer.filter.0":  
> > > "my\_edge\_ngram\_filter",  
> > > "index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_analyzer.tokenizer":  
> > > "keyword",  
> > > "index.analysis.filter.my\_edge\_ngram\_filter.min\_gram": "2",  
> > > "index.analysis.filter.my\_edge\_ngram\_filter.max\_gram": "30"  
> > > }  
> > > }  
> > > }
> > > 
> > > After that with Adrien suggestion i tried create the analyzer
> > > 
> > > "analysis" : {  
> > > "analyzer" : {  
> > > "keyword\_lowercase\_analyzer" : {  
> > > "tokenizer" : "keyword",  
> > > "filter" : ["lowercase"]  
> > > }  
> > > }  
> > > }
> > > 
> > > and recreate the mapping with :
> > > 
> > > "DISPLAY\_NAME": {
> > > 
> > > ```
> > > "type": "string",
> > > "search_analyzer" : "keyword_lowercase_analyzer"
> > > 
> > > ```
> > > 
> > > }
> > > 
> > > however with this configuration it wasn't able to search via "hap" to  
> > > return the following result :
> > > 
> > > _1)Happy_  
> > > _2)Happy birthday_  
> > > _3)Happy valentine_
> > > 
> > > Thanks
> > > 
> > > On Mon, Apr 28, 2014 at 8:17 PM, Dan Tuffery [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > 
> > > > As Adrien said don't apply the edge n-gram filter at search time. When  
> > > > you tried it what does you mapping look like, because "hap" should return a  
> > > > result.
> > > > 
> > > > Dan
> > > > 
> > > > On Monday, April 28, 2014 12:41:38 PM UTC+1, cyrilforce wrote:
> > > > 
> > > > > Hi dan
> > > > > 
> > > > > I tried this before however it returns me some irrelevant result as  
> > > > > well :  
> > > > > [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> > > > > 
> > > > > How I could get only the relevant result with the sorting via edge  
> > > > > ngram ? Thanks  
> > > > > On Apr 28, 2014 7:36 PM, "Dan Tuffery" [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > > 
> > > > > > To return the query results in the order you want, execute the sort  
> > > > > > on a not\_analyzed version of the term, i.e
> > > > > > 
> > > > > > "DISPLAY\_NAME": {  
> > > > > > "type": "string",  
> > > > > > "fields": {  
> > > > > > "NAME": {  
> > > > > > "type": "string",  
> > > > > > "analyzer": "edge\_ngram\_keyword\_lowercase\_analyzer"  
> > > > > > },  
> > > > > > "untouched":{  
> > > > > > "type": "string",  
> > > > > > "analyzer":"not\_analyzed"  
> > > > > > }  
> > > > > > }  
> > > > > > }
> > > > > > 
> > > > > > Reindex the data. Now in your query you can sort on the 'untouched'  
> > > > > > field:
> > > > > > 
> > > > > > {  
> > > > > > "from" : "0",  
> > > > > > "size" : "20",  
> > > > > > "explain" : true,
> > > > > > 
> > > > > > ```
> > > > > > "query" : {
> > > > > > "multi_match": {
> > > > > > "query": "happy",
> > > > > > "fields": ["DISPLAY_NAME.name"]
> > > > > > }
> > > > > > },
> > > > > > "sort" : [{ 
> > > > > > "DISPLAY_NAME.untouched" : { "order" : "desc"}}] 
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > }
> > > > > > 
> > > > > > which will return
> > > > > > 
> > > > > > _1)Happy_  
> > > > > > _2)Happy birthday_  
> > > > > > _3)Happy valentine_
> > > > > > 
> > > > > > Dan
> > > > > > 
> > > > > > On Monday, April 28, 2014 9:50:44 AM UTC+1, cyrilforce wrote:
> > > > > > 
> > > > > > > Hi All,
> > > > > > > 
> > > > > > > I am trying to use \*edge-ngram filter \*to achieve auto-completion  
> > > > > > > behaviour. However when i run the following query :
> > > > > > > 
> > > > > > > {  
> > > > > > > "from" : "0",  
> > > > > > > "size" : "20",  
> > > > > > > "explain" : true,
> > > > > > > 
> > > > > > > ```
> > > > > > > "query" : {
> > > > > > > *"multi_match": {*
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > - 
> > > > > > > 
> > > > > > > ```
> > > > > > > "query": "happy",*
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > - 
> > > > > > > 
> > > > > > > ```
> > > > > > > "fields": ["DISPLAY_NAME.NAME <http://DISPLAY_NAME.NAME>"]*
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > - 
> > > > > > > 
> > > > > > > ```
> > > > > > > }*
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > },  
> > > > > > > "sort" : [{  
> > > > > > > "\_score" : { "order" : "desc"}}]  
> > > > > > > }
> > > > > > > 
> > > > > > > It returns me documents :
> > > > > > > 
> > > > > > > [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> > > > > > > 
> > > > > > > May i know how can i achieve the behaviour when i search "_happy_"  
> > > > > > > then is should return me following result instead :
> > > > > > > 
> > > > > > > _1)Happy_  
> > > > > > > _2)Happy birthday_  
> > > > > > > _3)Happy valentine_
> > > > > > > 
> > > > > > > The analzyer configure :
> > > > > > > 
> > > > > > > "analysis" : {  
> > > > > > > "analyzer" : {  
> > > > > > > "edge\_ngram\_keyword\_lowercase\_analyzer" : {  
> > > > > > > "tokenizer" : "keyword",  
> > > > > > > "filter" : ["my\_edge\_ngram\_filter","lowercase"]  
> > > > > > > }  
> > > > > > > },  
> > > > > > > "filter" : {  
> > > > > > > "my\_edge\_ngram\_filter" : {  
> > > > > > > "type" : "edgeNGram",  
> > > > > > > "min\_gram" : "2",  
> > > > > > > "max\_gram" : "30"
> > > > > > > 
> > > > > > > ```
> > > > > > > }
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > }
> > > > > > > 
> > > > > > > The mapping :  
> > > > > > > [irrevelent\_response\_ngram\_edge\_mapping.json · GitHub](https://gist.github.com/cheehoo/11365917)
> > > > > > > 
> > > > > > > Thanks.
> > > > > > > 
> > > > > > > --  
> > > > > > > You received this message because you are subscribed to a topic in  
> > > > > > > the Google Groups "elasticsearch" group.  
> > > > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/to](https://groups.google.com/d/to)  
> > > > > > > pic/elasticsearch/fhsCgFBF76E/unsubscribe.  
> > > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > > > > 
> > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40goo  
> > > > > > [glegroups.com](http://glegroups.com)[https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > .  
> > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to a topic in the  
> > > > > Google Groups "elasticsearch" group.  
> > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > topic/elasticsearch/fhsCgFBF76E/unsubscribe.  
> > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%  
> > > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > .
> > > > 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > Regards,
> > > 
> > > Chee Hoo
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe](https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe).  
> > To unsubscribe from this group and all its topics, send an email to  
> > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/f296c0d1-0248-4d62-aba4-057373596343%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f296c0d1-0248-4d62-aba4-057373596343%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f296c0d1-0248-4d62-aba4-057373596343%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f296c0d1-0248-4d62-aba4-057373596343%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Regards,
> 
> Chee Hoo

--  
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/a49fed20-b734-42ac-ad51-ee9947ebe909%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a49fed20-b734-42ac-ad51-ee9947ebe909%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![cyrilforce](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@cyrilforce](https://discuss.elastic.co/u/cyrilforce)\
**Post date:** [April 30, 2014, 2:21am UTC](https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226/11 "2014-04-30T02:21:40Z")

</div>

Nice. Thanks.

On Tue, Apr 29, 2014 at 2:03 AM, Dan Tuffery [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> You could use a function score query and use the field length as the score:
> 
> {  
> "from": "0",  
> "size": "20",  
> "explain": true,  
> "query": {  
> "function\_score": {  
> "query": {  
> "multi\_match": {  
> "query": "happy",  
> "fields": [  
> "DISPLAY\_NAME.name"  
> ]  
> }  
> },  
> "script\_score": {  
> "script": "\_score =  
> pow(doc['DISPLAY\_NAME.untouched'].value.length(), -1)"  
> }  
> }  
> }  
> }
> 
> Dan
> 
> On Monday, April 28, 2014 3:08:24 PM UTC+1, cyrilforce wrote:
> 
> > Hi Dan,
> > 
> > It worked ! Btw one more questions. Now the result returned me the same  
> > scores for all :
> > 
> > 1)"\_score": 1.6931472,  
> > "\_source": {  
> > "DISPLAY\_NAME": "Happy Tears",
> > 
> > 1. "\_score": 1.6931472,  
> > "\_source": {  
> > "DISPLAY\_NAME": "Happy Happy Sangeethalu",
> > 
> > 3)"\_score": 1.6931472,  
> > "\_source": {  
> > "DISPLAY\_NAME": "Happy",
> > 
> > Anyway to manipulate the 3) to appear first ?
> > 
> > \*The query : \*
> > 
> > {  
> > "explain" : true,  
> > "query" : {  
> > "multi\_match": {  
> > "query": "happy",  
> > "fields": ["DISPLAY\_NAME.AUTOCOMPLETE"]  
> > }  
> > },  
> > "sort" : [{  
> > "\_score" : { "order" : "desc"},  
> > "DISPLAY\_NAME.NAME" : { "order" : "asc" }}]  
> > }
> > 
> > Thanks.
> > 
> > On Mon, Apr 28, 2014 at 9:43 PM, Dan Tuffery [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > 
> > > Change your mapping to:
> > > 
> > > DISPLAY\_NAME": {  
> > > "type": "multi\_field",  
> > > "fields": {  
> > > "AUTOCOMPLETE": {  
> > > "type": "string",  
> > > "index\_analyzer": "edge\_ngram\_keyword\_lowercase\_  
> > > analyzer",  
> > > "include\_in\_all": false  
> > > },  
> > > "NAME": {  
> > > "type": "string",  
> > > "analyzer": "standard",  
> > > "include\_in\_all": false  
> > > }  
> > > }  
> > > }
> > > 
> > > the DISPLAY\_NAME term will be indexed using  
> > > 'edge\_ngram\_keyword\_lowercase\_analyzer'. When you search on DISPLAY\_NAME
> > > 
> > > On Monday, April 28, 2014 2:31:24 PM UTC+1, cyrilforce wrote:
> > > 
> > > > Hi Dan,
> > > > 
> > > > Not sure whether i have same understanding "_edge n-gram filter at  
> > > > search time_" refer to apply edge n-gram filter in the query ? If this  
> > > > is the case i think i didn't apply any analyzer in the query :
> > > > 
> > > > \*Here my query : \*
> > > > 
> > > > {  
> > > > "query" : {  
> > > > "multi\_match": {  
> > > > "query": "happy",  
> > > > "fields": ["DISPLAY\_NAME.AUTOCOMPLETE"]  
> > > > }  
> > > > },  
> > > > "sort" : [{  
> > > > "\_score" : { "order" : "desc"},  
> > > > "DISPLAY\_NAME.NAME" : { "order" : "asc" }}]  
> > > > }
> > > > 
> > > > \*The result : \*  
> > > > [edge\_ngram\_original.json · GitHub](https://gist.github.com/cheehoo/11371837)
> > > > 
> > > > As you notice in the result it returned :
> > > > 
> > > > Happenings  
> > > > Happier?
> > > > 
> > > > which aren't part of what i searched for.
> > > > 
> > > > \*The mapping : \*  
> > > > [edge\_ngram\_mapping\_original.json · GitHub](https://gist.github.com/cheehoo/11371897)
> > > > 
> > > > \*The index : \*  
> > > > {  
> > > > "jdbc\_dev": {  
> > > > "settings": {  
> > > > "index.number\_of\_shards": "5",  
> > > > "index.number\_of\_replicas": "1",  
> > > > "index.version.created": "900299",  
> > > > "index.analysis.filter.my\_edge\_ngram\_filter.type":  
> > > > "edgeNGram",  
> > > > "index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_  
> > > > analyzer.filter.1": "lowercase",  
> > > > "index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_  
> > > > analyzer.filter.0": "my\_edge\_ngram\_filter",  
> > > > "index.analysis.analyzer.edge\_ngram\_keyword\_lowercase\_  
> > > > analyzer.tokenizer": "keyword",  
> > > > "index.analysis.filter.my\_edge\_ngram\_filter.min\_gram": "2",  
> > > > "index.analysis.filter.my\_edge\_ngram\_filter.max\_gram": "30"  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > After that with Adrien suggestion i tried create the analyzer
> > > > 
> > > > "analysis" : {  
> > > > "analyzer" : {  
> > > > "keyword\_lowercase\_analyzer" : {  
> > > > "tokenizer" : "keyword",  
> > > > "filter" : ["lowercase"]  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > and recreate the mapping with :
> > > > 
> > > > "DISPLAY\_NAME": {
> > > > 
> > > > ```
> > > > "type": "string",
> > > > "search_analyzer" : "keyword_lowercase_analyzer"
> > > > 
> > > > ```
> > > > 
> > > > }
> > > > 
> > > > however with this configuration it wasn't able to search via "hap" to  
> > > > return the following result :
> > > > 
> > > > _1)Happy_  
> > > > _2)Happy birthday_  
> > > > _3)Happy valentine_
> > > > 
> > > > Thanks
> > > > 
> > > > On Mon, Apr 28, 2014 at 8:17 PM, Dan Tuffery [dan.t...@gmail.com](mailto:dan.t...@gmail.com)wrote:
> > > > 
> > > > > As Adrien said don't apply the edge n-gram filter at search time. When  
> > > > > you tried it what does you mapping look like, because "hap" should return a  
> > > > > result.
> > > > > 
> > > > > Dan
> > > > > 
> > > > > On Monday, April 28, 2014 12:41:38 PM UTC+1, cyrilforce wrote:
> > > > > 
> > > > > > Hi dan
> > > > > > 
> > > > > > I tried this before however it returns me some irrelevant result as  
> > > > > > well :  
> > > > > > [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> > > > > > 
> > > > > > How I could get only the relevant result with the sorting via edge  
> > > > > > ngram ? Thanks  
> > > > > > On Apr 28, 2014 7:36 PM, "Dan Tuffery" [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > > > 
> > > > > > > To return the query results in the order you want, execute the  
> > > > > > > sort on a not\_analyzed version of the term, i.e
> > > > > > > 
> > > > > > > "DISPLAY\_NAME": {  
> > > > > > > "type": "string",  
> > > > > > > "fields": {  
> > > > > > > "NAME": {  
> > > > > > > "type": "string",  
> > > > > > > "analyzer": "edge\_ngram\_keyword\_lowercase\_analyzer"  
> > > > > > > },  
> > > > > > > "untouched":{  
> > > > > > > "type": "string",  
> > > > > > > "analyzer":"not\_analyzed"  
> > > > > > > }  
> > > > > > > }  
> > > > > > > }
> > > > > > > 
> > > > > > > Reindex the data. Now in your query you can sort on the 'untouched'  
> > > > > > > field:
> > > > > > > 
> > > > > > > {  
> > > > > > > "from" : "0",  
> > > > > > > "size" : "20",  
> > > > > > > "explain" : true,
> > > > > > > 
> > > > > > > ```
> > > > > > > "query" : {
> > > > > > > "multi_match": {
> > > > > > > "query": "happy",
> > > > > > > "fields": ["DISPLAY_NAME.name"]
> > > > > > > }
> > > > > > > },
> > > > > > > "sort" : [{
> > > > > > > "DISPLAY_NAME.untouched" : { "order" : "desc"}}]
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > }
> > > > > > > 
> > > > > > > which will return
> > > > > > > 
> > > > > > > _1)Happy_  
> > > > > > > _2)Happy birthday_  
> > > > > > > _3)Happy valentine_
> > > > > > > 
> > > > > > > Dan
> > > > > > > 
> > > > > > > On Monday, April 28, 2014 9:50:44 AM UTC+1, cyrilforce wrote:
> > > > > > > 
> > > > > > > > Hi All,
> > > > > > > > 
> > > > > > > > I am trying to use \*edge-ngram filter \*to achieve auto-completion  
> > > > > > > > behaviour. However when i run the following query :
> > > > > > > > 
> > > > > > > > {  
> > > > > > > > "from" : "0",  
> > > > > > > > "size" : "20",  
> > > > > > > > "explain" : true,
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > "query" : {
> > > > > > > > *"multi_match": {*
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > 
> > > > > > > > - 
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > "query": "happy",*
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > 
> > > > > > > > - 
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > "fields": ["DISPLAY_NAME.NAME <http://DISPLAY_NAME.NAME>"]*
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > 
> > > > > > > > - 
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > }*
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > 
> > > > > > > > },  
> > > > > > > > "sort" : [{  
> > > > > > > > "\_score" : { "order" : "desc"}}]  
> > > > > > > > }
> > > > > > > > 
> > > > > > > > It returns me documents :
> > > > > > > > 
> > > > > > > > [irrevelent\_response\_edge\_ngram.json · GitHub](https://gist.github.com/cheehoo/11365794)
> > > > > > > > 
> > > > > > > > May i know how can i achieve the behaviour when i search "_happy_"  
> > > > > > > > then is should return me following result instead :
> > > > > > > > 
> > > > > > > > _1)Happy_  
> > > > > > > > _2)Happy birthday_  
> > > > > > > > _3)Happy valentine_
> > > > > > > > 
> > > > > > > > The analzyer configure :
> > > > > > > > 
> > > > > > > > "analysis" : {  
> > > > > > > > "analyzer" : {  
> > > > > > > > "edge\_ngram\_keyword\_lowercase\_analyzer" : {  
> > > > > > > > "tokenizer" : "keyword",  
> > > > > > > > "filter" : ["my\_edge\_ngram\_filter","lowercase"]  
> > > > > > > > }  
> > > > > > > > },  
> > > > > > > > "filter" : {  
> > > > > > > > "my\_edge\_ngram\_filter" : {  
> > > > > > > > "type" : "edgeNGram",  
> > > > > > > > "min\_gram" : "2",  
> > > > > > > > "max\_gram" : "30"
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > }
> > > > > > > > }
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > 
> > > > > > > > }
> > > > > > > > 
> > > > > > > > The mapping :  
> > > > > > > > [irrevelent\_response\_ngram\_edge\_mapping.json · GitHub](https://gist.github.com/cheehoo/11365917)
> > > > > > > > 
> > > > > > > > Thanks.
> > > > > > > > 
> > > > > > > > --  
> > > > > > > > You received this message because you are subscribed to a topic in  
> > > > > > > > the Google Groups "elasticsearch" group.  
> > > > > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/to](https://groups.google.com/d/to)  
> > > > > > > > pic/elasticsearch/fhsCgFBF76E/unsubscribe.  
> > > > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > > > > > 
> > > > > > > To view this discussion on the web visit  
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed](https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed)  
> > > > > > > 3-474e-893d-92cc788003b0%[40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > > .  
> > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to a topic in the  
> > > > > > Google Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/to](https://groups.google.com/d/to)  
> > > > > > pic/elasticsearch/fhsCgFBF76E/unsubscribe.  
> > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40goo  
> > > > > > [glegroups.com](http://glegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f7b7df20-4136-4cb6-9dcc-318502ac05f9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > .
> > > > > 
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > Regards,
> > > > 
> > > > Chee Hoo
> > > 
> > > --  
> > > You received this message because you are subscribed to a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > topic/elasticsearch/fhsCgFBF76E/unsubscribe.  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/f296c0d1-0248-4d62-aba4-057373596343%  
> > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f296c0d1-0248-4d62-aba4-057373596343%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f296c0d1-0248-4d62-aba4-057373596343%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > Regards,
> > 
> > Chee Hoo
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe](https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/a49fed20-b734-42ac-ad51-ee9947ebe909%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a49fed20-b734-42ac-ad51-ee9947ebe909%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/a49fed20-b734-42ac-ad51-ee9947ebe909%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a49fed20-b734-42ac-ad51-ee9947ebe909%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Regards,

Chee Hoo

--  
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/CAGS0%2Bg-7j%3Dwbw9kx6iVMuQfXoJt5k1JU3M%3Dk77B-rwb0-1RkKQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGS0%2Bg-7j%3Dwbw9kx6iVMuQfXoJt5k1JU3M%3Dk77B-rwb0-1RkKQ%40mail.gmail.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:32am UTC](https://discuss.elastic.co/t/edge-ngram-returns-irrelevant-result/17226/12 "2017-07-06T01:32:34Z")

</div>


