Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

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

elasticsearch - Auto complete in elastic search

I am trying to create an auto-complete feature using elastic search for my e-commerce database. It has an index of products each of which is identified by attributes like color, size, category, bu.

What I want is when the user searches for "Re" it should suggest "Red", "Regular", "Reddish" and so on sorted by the count of products that have that attribute. So if 100 documents have "Red" and 50 have "Reddish", "Red" will appear on top. Since I am suggesting, I want the second meaningful word to go along with it as well. For e.g. along with "Red" as a suggestion, I want to show "Red Dress", "Red Shirt" and so on. The logic again is to find all the documents that have the maximum number of documents for the second word.

For e.g, if a user searches for "Re", the suggestion will be "Red Dress", followed by "Red Shirt" and then "Reddish Skirt". It will find all that starts with "Re" sorted by count, then find all the documents that have "Red" and suggest "Dress" before "Shirt" assuming "Dress" has more count than "Shirt".

question from:https://stackoverflow.com/questions/65856228/auto-complete-in-elastic-search

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

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...