Hi
I'm trying to implement search functionality in our project using Nest. I have following query:
query
.Bool(must => must
.Filter(m => m
.MultiMatch(qs => qs
.Type(TextQueryType.CrossFields)
.Lenient(true)
.Fields(fields => fields
.Field(item => item.Username)
.Field(item => item.Name)
.Field(item => item.Surname)
.Field(item => item.FavColor)
.Field(item => item.Description)
.Field(item => item.ClientNumber)
.Field(item => item.Code)
.Field(item => item.Options)
.Field(item => item.Equipment)
.Field(item => item.Year)
.Field(item => item.Status))
.MinimumShouldMatch(MinimumShouldMatch.Percentage(100))
.Query(filters?.SearchText ?? string.Empty)
Fields have diffrent analyzers:
- Edge-Ngram
- Ngram
- Keyword
When I enter the search query, f.e. John Redling, I want get only the documents, that have all words from search phase, but each word can be found in separate fields, for example user with name John o Johnny(edge-ngram analyzer) and surname starting with Redling.
My problem is, that currently, having ngrams make this difficult. It the exmple above Redling produces ngrams: red, edl, dli, etc. I set MinimumShouldMatch to 100%, but still it can find red in color and ling in different field and it's 100%, but it's not document i'm looking for.
Is there a better way to implement it?