简体   繁体   中英

ruby on rails sunspot solr search show some specific results on top

I'm using Sunspot Solr for indexing and searching in our Rails application

search = Product.search do 
            with(:categoery, [1,2,3])
            order_by(:priority)
            #and some other filters
         end

But for some specific Users i want to display some product with id suppose [8,9] ordered on-top of search result and then other products(as i don't want to discard other results), is it possible in same search query?

Have a look at the Query Elevation Component :

The Query Elevation Component lets you configure the top results for a given query regardless of the normal Lucene scoring. This is sometimes called "sponsored search," "editorial boosting," or "best bets." This component matches the user query text to a configured map of top results.

The text can be any string or non-string IDs, as long as it's indexed. Although this component will work with any QueryParser, it makes the most sense to use with DisMax or eDisMax.

The Query Elevation Component is supported by distributed searching.

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