# EdgeNGrams with Fuzzy not working perfect

**URL:** <https://discuss.elastic.co/t/edgengrams-with-fuzzy-not-working-perfect/80437>\
**Category:** Elasticsearch\
**Created:** [March 29, 2017, 8:29am UTC](https://discuss.elastic.co/t/edgengrams-with-fuzzy-not-working-perfect/80437 "2017-03-29T08:29:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grigorios\_Loukidis](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@Grigorios\_Loukidis](https://discuss.elastic.co/u/Grigorios_Loukidis)\
**Post date:** [March 29, 2017, 8:29am UTC](https://discuss.elastic.co/t/edgengrams-with-fuzzy-not-working-perfect/80437/1 "2017-03-29T08:29:16Z")

</div>

I am using elastic and I am cuurently satisfied with my searches relevance except of one ocassion.For example If I am searching for the world "play" I will get docs containing wold "plays" with higher score than these ones with word "play".And that happens because I am using edgeNgrams(on indexing) with Fuzziness.Auto(on searching).Is there any filter or method to boost the exact ones than the fuzzy ones?

Here is code for indexing

```
var response = client.CreateIndex(index, s => s
.Settings(s1 => s1.NumberOfShards(1).NumberOfReplicas(1)
.Analysis(a => a.TokenFilters(t => t.EdgeNGram("edge", ed => ed.MaxGram(50).MinGram(1).Side(EdgeNGramSide.Front))
.Lowercase("lowercase", gl => gl.Language(Language.Greek.ToString())).KeywordMarker("keywords", gk => gk.Keywords("")))
.Analyzers(a1 => a1.Custom("forindex", t => t.Tokenizer("standard")
.Filters("edge", "lowercase", "keywords" ))
.Custom("forsearch", cu => cu.Tokenizer("standard")
.Filters("lowercase", "keywords"))))));

```

And here for searching

```
var query = new MatchQuery()
                        {
                            Query = searchWord,
                            Operator = Operator.And,
                            Field = fieldName,
                            Fuzziness = Fuzziness.Auto,
                            PrefixLength = 1,
                            Analyzer = "forsearch"
                        };
```

---

<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:** [March 29, 2017, 8:57am UTC](https://discuss.elastic.co/t/edgengrams-with-fuzzy-not-working-perfect/80437/2 "2017-03-29T08:57:39Z")

</div>

What version of Elasticsearch is it? All 5.x releases and recent 2.x releases are supposed to have [https://issues.apache.org/jira/browse/LUCENE-329](https://issues.apache.org/jira/browse/LUCENE-329) in, which makes all expanded terms use the same index stats.

---

<div class="post-metadata">

**Author:** ![Grigorios\_Loukidis](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@Grigorios\_Loukidis](https://discuss.elastic.co/u/Grigorios_Loukidis)\
**Post date:** [March 29, 2017, 9:14am UTC](https://discuss.elastic.co/t/edgengrams-with-fuzzy-not-working-perfect/80437/3 "2017-03-29T09:14:40Z")

</div>

its 5.2

---

<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:** [March 29, 2017, 4:10pm UTC](https://discuss.elastic.co/t/edgengrams-with-fuzzy-not-working-perfect/80437/4 "2017-03-29T16:10:39Z")

</div>

Could you share a recreation of this issue?

---

<div class="post-metadata">

**Author:** ![Grigorios\_Loukidis](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@Grigorios\_Loukidis](https://discuss.elastic.co/u/Grigorios_Loukidis)\
**Post date:** [March 30, 2017, 5:57am UTC](https://discuss.elastic.co/t/edgengrams-with-fuzzy-not-working-perfect/80437/5 "2017-03-30T05:57:49Z")

</div>

Sorry Adrien, I didn't catch it.What do you mean?

---

<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:** [March 30, 2017, 6:10am UTC](https://discuss.elastic.co/t/edgengrams-with-fuzzy-not-working-perfect/80437/6 "2017-03-30T06:10:43Z")

</div>

He meant a script like the example in:

> **[Elasticsearch](https://discuss.elastic.co/c/elasticsearch)**
>
> Any questions related to Elasticsearch, including specific features, language clients and plugins.

---

<div class="post-metadata">

**Author:** ![Grigorios\_Loukidis](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@Grigorios\_Loukidis](https://discuss.elastic.co/u/Grigorios_Loukidis)\
**Post date:** [March 30, 2017, 7:12am UTC](https://discuss.elastic.co/t/edgengrams-with-fuzzy-not-working-perfect/80437/7 "2017-03-30T07:12:08Z")

</div>

I noticed that if I change edgeNGram side from Front to Back works fine, but I need an example on how edgeNGram back works.

---

<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:** [March 30, 2017, 7:25am UTC](https://discuss.elastic.co/t/edgengrams-with-fuzzy-not-working-perfect/80437/8 "2017-03-30T07:25:52Z")

</div>

Note that side has been deprecated and will be removed in the future.

Read

> [@Edge\_ngram anchoring to the back](https://discuss.elastic.co/t/edge-ngram-anchoring-to-the-back/80479/2):
>
> You can use a combination of: [https://www.elastic.co/guide/en/elasticsearch/reference/5.3/analysis-reverse-tokenfilter.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/analysis-reverse-tokenfilter.html)[https://www.elastic.co/guide/en/elasticsearch/reference/5.3/analysis-edgengram-tokenfilter.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/analysis-edgengram-tokenfilter.html) ["reverse", "edge", "reverse"] so it will produce: [kciuQ] [kc, kci, kciu, kciuQ] [ck, ick, uick, Quick] Thanks to @jpountz for the solution. slight_smile

---

<div class="post-metadata">

**Author:** ![Grigorios\_Loukidis](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@Grigorios\_Loukidis](https://discuss.elastic.co/u/Grigorios_Loukidis)\
**Post date:** [March 30, 2017, 7:46am UTC](https://discuss.elastic.co/t/edgengrams-with-fuzzy-not-working-perfect/80437/9 "2017-03-30T07:46:16Z")

</div>

Its not exaclty what I need, but than you for your important help!!

---

<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:** [April 27, 2017, 7:46am UTC](https://discuss.elastic.co/t/edgengrams-with-fuzzy-not-working-perfect/80437/10 "2017-04-27T07:46:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
