Using Elasticsearch Nest Client to search for company name store in Elasticsearch. Here is sample of my queryExtentions.
I want to change it to make sure when I search for "Starbucks", it should only return record starting with letter "Starbucks". Currently it is rerurning all the records where it has "StarBucks". Based on documentation, I need to search on "Keyword" filed in order to get the result. Need sample code to how to achieve this.
****Elastic Search Index Column"
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
Code* var escapedSearchTerm = ElasticsearchQueryExtensions.EscapeQuery(companyName); return new QueryContainerDescriptor().Bool(b => b.Must(mu => mu .QueryString(qs => qs .AllowLeadingWildcard(true) .AnalyzeWildcard(true) .Fields(f => f.Field(s => s.Company.Name).Field(s => s.Organization.CommonName)) .Query(escapedSearchTerm) )));