I'm attempting to utilize Elasticsearch's 'Suggester' functionality.
Using Phrase, Term, or Completion I always get the following error variation.
unable to parse SuggestionBuilder with name [COMPLETION]: parser not found"
unable to parse SuggestionBuilder with name [TERM]: parser not found"
unable to parse SuggestionBuilder with name [PHRASE]: parser not found"
I have tried multiple 6.x NEST versions and they all have the same issue. Upgrading to 7.0alpha1 does change the error, but seems to cause a myriad of other issues, and I rather not use an alpha library in production.
I'm currently following this tutorial and working it into my existing code: https://github.com/elastic/elasticsearch-net-example/tree/6.x-codecomplete-netcore#part-6-suggestions
Currently using NEST 6.1
Model:
public class SearchResult {
public SearchResult()
{
TitleSuggest = new CompletionField {Input = new List<string>(Title.Split(' '))};
}
public CompletionField TitleSuggest { get; set; }
//etc
}
Index Method:
public async Task<IActionResult> CreateIndex()
{
await _searchClient.CreateIndexAsync(SearchIndexName, indexSelector =>
indexSelector
.Mappings(mappingsDescriptor =>
mappingsDescriptor.Map<Models.SearchResult>(y => y.AutoMap().Properties(pr=>pr.Completion(c => c.Name(p => p.TitleSuggest)
))))
Suggest Method:
public async Task<ISearchResponse<SearchResult>> Suggest(string keyword)
{
return await _searchClient.SearchAsync<SearchResult>(
s =>
s.Suggest(ss => ss
.Completion("title", cs => cs
.Field(f => f.TitleSuggest)
.Prefix(keyword)
.Fuzzy(f => f
.Fuzziness(Fuzziness.Auto)
)
.Size(5))
}
I'm having a hard time deciphering the error. It seems as though the NEST libraries are missing the Suggester parsers? Any help would be great, thanks!
As a follow up, @RussCam answered my question here
I had a ConnectionSetting (DefaultFieldNameInferrer) that was uppercasing my suggester
private IElasticClient ElasticClient(IConfiguration _config, string defaultIndex)
{
var settings = new ConnectionSettings(new Uri(_config.GetSection("Search:Url").Value))
.BasicAuthentication(_config.GetSection("Search:User").Value, _config.GetSection("Search:Password").Value)
.DefaultIndex(_config.GetSection(defaultIndex).Value);
//settings.DefaultFieldNameInferrer(p => p.ToUpper(CultureInfo.CurrentCulture));
//Enable ElasticSearch Debugging
settings.PrettyJson().DisableDirectStreaming();
return new ElasticClient(settings);
}