0
votes

I have AutoComplete working with ElasticSearch (Nest) and it's fine when the user types in the letters from the begining of the phrase but I would like to be able to use a specialized type of auto complete if it's possible that caters for words in a sentence.

To clarify further, my requirement is to be able to "auto complete" like such:

Imagine the full indexed string is "this is some title". When the user types in "th", this comes back as a suggestion with my current code.

I would also like the same thing to be returned if the user types in "som" or "title" or any letters that form a word (word being classified as a string between two spaces or the start/end of the string).

The code I have is:

var result = _client.Search<ContentIndexable>(
            body => body
                        .Index(indexName)
                        .SuggestCompletion("content-suggest" + Guid.NewGuid(),
                                           descriptor =>
                                           descriptor
                                               .OnField(t => t.Title.Suffix("completion"))
                                               .Text(searchTerm)
                                               .Size(size)));

And I would like to see if it would be possible to write something that matches my requirement using SuggestCompletion (and not by doing a match query).

Many thanks,

Update: This question already has an answer here but I leave it here since the title/description is probably a little easier to search by search engines.

The correct solution to this problem can be found here: Elasticsearch NEST client creating multi-field fields with completion

1

1 Answers

0
votes

@Kha i think it's better to use the NGram Tokenizer

So you should use this tokenizer when you create the mapping. If you want more info, and maybe an example write back.