I have an application (.net core + ReactJS) that I have to figure out and make a mod, but come to find out that it is using a lot of technologies that I am not familiar with, in this case, ElasticSearch. Currently, a search of a term Micro, will not return anything, because apparently, it is looking for an exact match, but What I am trying to achieve is that a search for Micro should return Microsoft, MicroStrategy...and anything that contains "micro" in the name, how do I accomplish that in the following code? I tried to do some research, i see things like ngram, analyzer, query_string or QueryString...no idea where to start. Please help.
public SearchDescriptor<ProductRecord> BuildSearchDescriptor(
string productType,
string name,
int page ,
int pageSize ,
Dictionary<string, List<string>> filters)
{
ValidateProductType(productType);
var collection = ProductTypeToCollection[productType];
var searchDescriptor = new SearchDescriptor<ProductRecord>()
.Index(collection)
.From(page * pageSize)
.Size(pageSize)
.Query(q => q
.Bool(bq => bq
.Must(m => m
.MultiMatch(c => c
.Query(name)
.Fields(ff => ff
.Field(f => f.Product, boost: ProductBoost)
.Field(f => f.Manufacturer, boost: ManufacturerBoost)
.Field(f => f.Version)
.Field(f => f.Id, boost: 50)
)
.Type(TextQueryType.CrossFields)
//.Type(TextQueryType.BestFields)
))
.Filter(fq => AddFilters(fq, filters))
)
)
.Sort(ss => ss
.Descending(SortSpecialField.Score)
.Ascending(p => p.Product.Suffix("keyword"))
.Ascending(p => p.Manufacturer.Suffix("keyword"))
.Descending(p => p.Version.Suffix("keyword"))
/*.Script(sc => sc
.Type("number")
.Descending()
.Script(script => script
.Source("doc['VERSION'].value")))
*/
);
return searchDescriptor;
}
}