# Strange search result nGram + Highlight

**URL:** <https://discuss.elastic.co/t/strange-search-result-ngram-highlight/210301>\
**Category:** Elasticsearch\
**Created:** [December 3, 2019, 7:09am UTC](https://discuss.elastic.co/t/strange-search-result-ngram-highlight/210301 "2019-12-03T07:09:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DesireeNordlund](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/desireenordlund/32/56925_2.png) [@DesireeNordlund](https://discuss.elastic.co/u/DesireeNordlund)\
**Post date:** [December 3, 2019, 7:09am UTC](https://discuss.elastic.co/t/strange-search-result-ngram-highlight/210301/1 "2019-12-03T07:09:27Z")

</div>

Since I added nGram to my index I have gained very strange search result. As far as I can see the index is correct, so I think it is my query that is wrong.

When I remove the Highlight part of the query I get what I belive is a correct search result, but when I add the part I get hits on just a very few things.

I have limited the number of fields to just two for debugging purpouses, and I have also tried to remove the whole field-list to get all fields.

I have also had highlights specified for all fields used, but that did not work either.

It is not the Filter part because I tested it before I started with nGram, and I have tried to remove it as well, making just a MultiMatchQuery.

Please, I feel I am going insane here. There must be some fundamental part I am missing.

```
        Explain = true,
        Size = 100,
        Sort = new List<ISort>
        {
            new FieldSort { Field = "_score", Order = SortOrder.Descending },
        },
        Query = new BoolQuery
        {
            Must = new QueryContainer[] { new MultiMatchQuery
                {
                    Query = searchString,
                    Fields = new Field("email.content.subject").And("email.content.body"),
                    Type = TextQueryType.MostFields,
                }
            },
            Filter = new QueryContainer[] { new MatchQuery
                {
                    Field = "authority",
                    Query = userauthority,
                    Operator = Operator.Or
                }
            },
        },
        Highlight = new Highlight  
        {
            PreTags = new[] { "###BEGINstrong###" },  
            PostTags = new[] { "###ENDstrong###" },
            Encoder = HighlighterEncoder.Html,
            BoundaryScanner = BoundaryScanner.Sentence,
            Fragmenter = HighlighterFragmenter.Span,
            NoMatchSize = 0,
            FragmentSize = 200,
            NumberOfFragments = 5,
            Fields = new Dictionary<Field, IHighlightField>
                             {
                                {
                                "*", new HighlightField 
                                    {

                                    }
                                }
                            }
        }
```

---

<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:** [December 31, 2019, 7:09am UTC](https://discuss.elastic.co/t/strange-search-result-ngram-highlight/210301/2 "2019-12-31T07:09:37Z")

</div>

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