简体   繁体   中英

Solr Search word proximity

I am using sunspot gem for the search functionality in rails app. I have issue in word proximity in solr search. Example i am searching for "Hello World", solr give me the proper result for the search. But in first document "Hello World" string is appears only once and in second document it appears two times.

but i want is if the string appears more in any document will come at top and string appears less come after the top result.

Help will be appreciate. Thanku

If your search field (I'll call it keywords) has omitNorms="true" means that the number of times the search term matches the keywords no longer matters. So set omitNorms to false in the schema.xml .

If you are using edismax the default boost of each field is 1, but you can boost more a specific field using caret (^). So if you want to have multiple matches, with search terms in the keywords field, to be shown much higher up in the search results you have to boost with an high factor and sort by score desc (default).

adjust_solr_params do |params|
  params[:fq] = "keywords_text:(your terms)^15"
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM