Solr.Net applying Sort function after fetched results from Solr

640 views
Skip to first unread message

Siva

unread,
Jan 8, 2013, 8:58:35 AM1/8/13
to sol...@googlegroups.com
Hi,
I am using solr.net one of my project. It was working beautifully.
Now our Client want difficult sort functionality.
Here is what we are trying to do:

we search products by keyword and solr returns product results, From the product result we want push some of the supplier products on the top of the result, which may vary different logged in users.

For Example :
we got products from Samsung and Sony,  If user1 logged in show samsung products top of the page. if user2 logged in we need show Sony Products, if user not logged in default solr sort.

how we can apply sort after we fetched results from solr.

 any help much appreciated!!!


Thanks
Regards
Siva

Mauricio Scheffer

unread,
Jan 8, 2013, 11:14:44 AM1/8/13
to sol...@googlegroups.com
You could set a bq ( http://wiki.apache.org/solr/DisMaxQParserPlugin#bq_.28Boost_Query.29 ) depending on what user is logged, assuming you're using dismax.



--
Mauricio



Siva

--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To view this discussion on the web visit https://groups.google.com/d/msg/solrnet/-/D4HTNOSnV1MJ.
To post to this group, send email to sol...@googlegroups.com.
To unsubscribe from this group, send email to solrnet+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/solrnet?hl=en.

Abaranji Sivakumar

unread,
Jan 9, 2013, 4:54:11 AM1/9/13
to sol...@googlegroups.com
Hi Mauricio,
Thank You very much for your reply..
My Code is like below to get the products from Solr.

var mySort = new[] {	
new SortOrder("specialoffer", Order.DESC),
new SortOrder("newproduct", Order.DESC),
new SortOrder("featured", Order.DESC),
};
var matchingProducts = solr.Query(sq, new QueryOptions
{
FilterQueries = BuildFilterQueries(parameters),
Rows = parameters.PageSize,
Start = start,
OrderBy = mySort,
Facet = new FacetParameters
{
Queries = AllFacetFields.Except(SelectedFacetFields(parameters))
.Select(f => new SolrFacetFieldQuery(f) { MinCount = 1 })
.Cast<ISolrFacetQuery>()
.ToList(),
Limit = 9999,
},

});
here I want pass Company name "Samsung" if user1 logged in and show samsung products on top of the result( can appear after the SortOrder) .

can you please help...

Thanks
Regards
Siva

Abaranji Sivakumar

unread,
Jan 9, 2013, 10:42:17 AM1/9/13
to sol...@googlegroups.com
Hi Mauricio,
I am able to get the sort working on the query using below link
http://stackoverflow.com/questions/12749669/conditional-sorting-in-solr-3-6

http://localhost:8080/solr/select/?q=:&sort=query({v='CurrentUserId:10330'})+desc,specialoffer desc


I got struck now passing the custom query to SortOrder (mysort) on the mvc application..
Can you please help...

Thanks
Regards
Siva

Mauricio Scheffer

unread,
Jan 9, 2013, 10:46:00 AM1/9/13
to sol...@googlegroups.com
If you're using explicit sorting instead of scoring, create new boolean fields isSamsung and isSony, populate them accordingly at index-time, then sort by that.



--
Mauricio

Abaranji Sivakumar

unread,
Jan 9, 2013, 10:47:48 AM1/9/13
to sol...@googlegroups.com
Hi,

I got the exact result what i want using
now passing the custom query in MVC is where i struck.


Thanks
Regards
Siva
Reply all
Reply to author
Forward
0 new messages