0

I am elasticsearch newbie.

I am trying to use elasticsearch to search some titles let's say books names.

From my client I am sending the user input string every 0.5 second to the server to give suggestions.

So it could be partial words and maybe typos.

What would be the best query/way to deal with that.

Any point on the right direction will be appreciated.

Thanks

// fuzzy query example but it is not answering for multiple words
return await client.search({
 index: indexName,
 body: {
   query: {
     fuzzy: {
       title: userInputSentence 
     }
   },
 },

});

barak
  • 869
  • 1
  • 11
  • 15
  • Please provide specific information you are looking for. This is too broad for SO .. read https://meta.stackoverflow.com/questions/351670/what-makes-this-question-too-broad – Amit Mar 04 '19 at 08:58
  • @AmitKhandelwal you might be right but on the other hand, I think this is a common usage to get a user input string and to look for it on the titles. – barak Mar 04 '19 at 09:20
  • https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html might be something which u are looking for.. let me know if you have question reg it – Amit Mar 04 '19 at 09:31

1 Answers1

0

You can achieve auto-complete by adding ngram/prefix tokenizers - this will make the partial text entered to match the docs with the full length text.

Few references: How to suggest (autocomplete) next word in elastic search?

https://hackernoon.com/elasticsearch-building-autocomplete-functionality-494fcf81a7cf

update:----------

Another option is to use Elasticsearch completion suggester and Index-Time Search-as-You-Type