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
{
}
}
}
}