Predictive autosuggest logic

随声附和 提交于 2019-12-08 13:26:41

问题


I would like to implement predictive autosuggest in my website. I have used Solr to improve search performance. But after a research of last 2 days, I understand that Solr didn't have any built in package or support to implement predictive suggestion like Amazon or flipkart search. Anybody can advice me what is the easy logic to implement predictive suggestion OR what are the technologies supports this type of search suggestion?

Expected workflow as follows,

If user search string "samsung" our autosuggestion should show grouped suggestion as follows,

  • samsung in Mobile
  • samsung in Television
  • samsung in Laptop

    and so on


回答1:


You're describing "filtered search" (via autosuggest). You can determine which filters to offer using Solr facets.

Assuming "Mobile", "Television" and "Laptop" are all values in a Solr field called category:

  1. Run a query for samsung with rows=0 and request a terms facet on category.
  2. You'll get back an frequency-ordered list of categories where documents match samsung
  3. Display these categories as filtered search options (via autosuggest) if you decide the result count is high enough.
  4. When a suggestion is chosen, run a second query for samsung filtered by the chosen category (eg: q=samsung&fq=category:Mobile&rows=10)


来源:https://stackoverflow.com/questions/30074681/predictive-autosuggest-logic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!