Solr Lucene Scoring and Sorting problems

I'm not having much luck finding Solr help, but hopefully someone can help.

I've just set up Solr and am able to do searches but am unable to sort and the default scoring doesn't seem to be working.  Does something need to be done to enable scoring and sorting in Solr?  

I've tried every example that I could find online, which Solr seems to completely ignore.  Neither of these did anything:

somewords ;Popularity desc
somewords &sort=Popularity desc

The scoring doesn't seem to be doing anything either.  My search results come back in the order that they are stored every time.  Exact matches are not ordered any higher than partials.

I know this isn't a specific sorlnet issue, but I don't know where to turn, as there is so little documentation to help.  Please advise.


Who is Participating?
cwiedmannConnect With a Mentor Commented:
All of these parameters turn into pretty simple query string parameters to Solr, so you should just be able to add start and rows generically.  From my reading of SolrNet they seemed to have a way of adding arbitrary parameters by passing in a Dictionary of values - I would try this if you can't find a more supported way of doing this.

Having said that, the performance issue is not likely to be caused by this since it's the server that defaults to 10 records, not the client.  Have you optimised your index? If the index is very fragmented, it'll affect performance.
You are adding the &sort= to the url, not to the query, right?  It would help if you can post the URL of the query.
JT_SIROAuthor Commented:
I'm using the Solrnet class to access Solr, so I don't actually build a URL per se.  I use the .Query method of Solrnet, like this:

        var solr = ServiceLocator.Current.GetInstance<ISolrOperations<TrackInfo>>();
        var results = solr.Query("keyword1 -ExcludeWord &sort=Popularity asc");

It searches the text I pass it, as well as exclude text, but the sort is ignored.

There's very little documentation on this.  Does it look like I'm using it incorrectly?
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

JT_SIROAuthor Commented:
I read that the string passed in the solr.Query() function is passed to the q parameter for Solr.

Additional name / value parameters can be accessed by SolrNet, but they need to be declared.  Maybe I need to create one for sort.

You'd think that sorting would be built in to solrnet

As you surmised, adding the &sort=Popularity asc to the q parameter won't work.  Just add a parameter "sort" with the value "Popularity asc".  It looks like you can do this in Solrnet by passing a dictionary with those values.
JT_SIROAuthor Commented:
cwiedmann - I'll give you the points - sorry for the delay and thanks.  I'm getting closer but still super slow searching...

Do you happen to know how to restrict the results set (documents) to 25?  I've limited my data grid to 25 results per page, but it's still very slow when say 1000 results come back.  I'm guessing this is because Solr is actually returning all 1000 recs, even though I'm only displaying 25.  It looks like my defaults are set for 10 in solrconfig, but it appears that Solrnet bi-passes that and gets everything.  

I also need to set my Start param so I can do paging.  I was able to figure out how to handle the Sort parameter, by adding the following to my Solr.Query:
new QueryOptions().AddOrder(new SolrNet.SortOrder("Popularity", Order.DESC)

But I don't see anything like this to set the Rows or Start parameters.  This should be so much easier, but it's clear that .NET users haven't worked with this much yet.  Please advise!

Thanks -

JT_SIROAuthor Commented:
Good information but no specific Solrnet examples.  Thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.