Following Elasticsearch's documentation here, we should specify our shingle subfields like in this example:
GET my-index-000001/_search
{
"query": {
"multi_match": {
"query": "brown f",
"type": "bool_prefix",
"fields": [
"my_field",
"my_field._2gram",
"my_field._3gram"
]
}
}
}
How can we strongly type specify these fields using NEST, Elasticsearch's official client?
ISearchRequest Selector(SearchDescriptor<PointOfInterest> s)
{
return s
.Index(IndexName)
.Query(q => q
.MultiMatch(c => c
.Fields(f => f
.Field(p => p.MyField) // This one we can easily specify
.Field("my_field._2gram") // This one needs to be hard coded? Field(p => $"{p.MyField}._2gram")) doesn't work
.Field("my_field._3gram"))
.Type(TextQueryType.BoolPrefix)
.Query(query.Query)));
}
Suffix
extension method will help you with this