We require assistance in creating the required query in Elasticsearch using the NEST library. We have managed to correctly index the data using a custom analyzer (character filters, Tokenizer and Token filters), but are having difficulty in creating a prefix query that ALSO analyzes the data.
It seems that you cannot use a prefix query if you want the query analyzed. But if you use a Match query, then results are returned if there is a match anywhere in the field as opposed to just the beginning which is why we need the prefix query.
We have indexed our data using a custom analyzer:
.Custom("lowercase", lc => lc.CharFilters("removepunctuation").Tokenizer("keyword").Filters("lowercase"))
we have also mapped this analyzer to the field:
.Text(s => s.Name(c => c.Name).Analyzer("lowercase")
However if we enter a prefix query the query is not analyzed. If we use a MatchPhrasePrefix the results that come back include records that contain the prefix ANYWHERE in the field - but we need to only return the results if it STARTS with the query.
Can anyone tell us what we need to do to achieve this?
Many thanks