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
1.3k 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
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

57.0k users

...