You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by "federico.wachs" <fe...@2clams.com> on 2012/01/19 20:50:32 UTC

Question about sorting by a field

Hi all, I've been working with solr for a few months now and so far I only
had a few issues trying to implement some functionality, but this has gone
above my current solr skills, so any help or guidance is greatly
appreciated.

I have a multivalued field consited which contains destinations like:
"Paris, Rome, London"
<doc id="1">
<destinations>
    <value=&quot;Buenos Aires&quot;/>
    <value=&quot;Paris&quot;/>
    <value=&quot;London&quot;/>
    <value=&quot;Rome&quot;/>
   </destinations>
</doc>
<doc id="2"> 
  <destinations>
    <value=&quot;London&quot;/>
    <value=&quot;Buenos Aires&quot;/>
    <value=&quot;Paris&quot;/>
    <value=&quot;Rome&quot;/>
   </destinations>
</doc>

Ok so those are my documents. Then I query searching documents containing
Buenos Aires as a destination, those two documents will come as results, so
far so good. 
Now, what is really important for me, is that the first results are the ones
that match the first destination, since the user will want to see those
first as well. 

My question is, how can I sort this results ? What should I use? Is there a
way to do this with Solr? 

I've been reading on how to pull this out by using boosts but that doesn't
seem to be working on my end so far.


Thanks in advanced!

Federico

--
View this message in context: http://lucene.472066.n3.nabble.com/Question-about-sorting-by-a-field-tp3673491p3673491.html
Sent from the Solr - User mailing list archive at Nabble.com.

RE: Question about sorting by a field

Posted by "federico.wachs" <fe...@2clams.com>.
Yes, that works! I had to boost the firstDestination field to have it well
sorted. Any ideas why the score might be equally for all the documents
returned?

Thanks a lot!
Federico

--
View this message in context: http://lucene.472066.n3.nabble.com/Question-about-sorting-by-a-field-tp3673491p3676815.html
Sent from the Solr - User mailing list archive at Nabble.com.

RE: Question about sorting by a field

Posted by Michael Ryan <mr...@moreover.com>.
How about having a single-valued field named "firstDestination" that has the first destination in the list, and then your query could be something like 'destination:"Buenos Aires" firstDestination:"Buenos Aires"'. Docs that match both should have a higher score and thus will be listed first.

-Michael