Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
692 views
in Technique[技术] by (71.8m points)

elasticsearch - How to suggest (autocomplete) next word in elastic search?

Lets say I have following strings indexed:

"My awesome pizza"
"My awesome beer"
"Heineken is awesome beer"
"I love pizza pepperoni"
"Where is my beer"

For input "My" I want to suggest:

  1. My awesome
  2. My beer

For input "awesome" I want to suggest:

  1. awesome pizza
  2. awesome beer

etc.

So I want to provide next words after user input... Also with some fuzziness (aEwsome) should be also supported.

Which suggesters/analyzers I should use? I tried Term and completion but it is not what I want (completion for example works only when search for start of the phrase - if I pass word that is in the middle of indexed string then it will not suggest it,)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just in case anyone bumps in here, the edge-n-gram approach (as noted by @Siddardha Budige) is now superseded by completion suggesters.

They are purposely built with auto-completion in mind, so they are fast end efficient. A very informative post By the ES team can be found here.

Two caveats:

  1. They are implemented by an in-memory Data-Structure (called a Finite State Transducer) and are therefore not suitable for large datasets that can't fit in memory.

  2. The ranking of the results is not based on similarity (a result either matches or not) so you have to be careful with blending fuzzy and non-fuzzy matches.

EDIT: We shared our own experience with using Completion Suggesters here.

It includes some practical examples on fuzzyness and info for non-English inputs.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...