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 wwhite1133 <ww...@gmail.com> on 2013/01/07 08:27:11 UTC

Sorting the search results based on number of highlights

Hi ,
 I wanted to sort the results of the solr search query on the number of
highlights generated per document. 
e.g  
Doc 1 
highlights {
fieldA
FieldB
}
Doc 2
Highlights{
field A 
fieldC
fieldC
}

No, I understand that score is calculated depending on many factors like ,
tf , idf boost etc. So when I sort on score the the document with 2
highlights can come ahead of the document with 3 highlights.
How can I sort based on purely the number of highlights. 
Right now I am doing it in the code but 
I do not want to do this in code  as then the pagination becomes an issue .
I have to fetch a larger number of records and do in memory sorting . 

Any help is appreciated.
Thanks 
WW



--
View this message in context: http://lucene.472066.n3.nabble.com/Sorting-the-search-results-based-on-number-of-highlights-tp4031175.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Sorting the search results based on number of highlights

Posted by Naresh <nn...@gmail.com>.
Can you set omitNorms to true in the fieldType and see if that helps? Check
http://wiki.apache.org/solr/SchemaXml#Common_field_options

On Fri, Jan 18, 2013 at 4:37 AM, wwhite1133 <ww...@gmail.com> wrote:

> Sorry, I did not understand what you mean. Can you pl. elaborate..
> Thanks
> WW
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Sorting-the-search-results-based-on-number-of-highlights-tp4031175p4034348.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 
Regards
Naresh

Re: Sorting the search results based on number of highlights

Posted by wwhite1133 <ww...@gmail.com>.
Sorry, I did not understand what you mean. Can you pl. elaborate..
Thanks
WW



--
View this message in context: http://lucene.472066.n3.nabble.com/Sorting-the-search-results-based-on-number-of-highlights-tp4031175p4034348.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Sorting the search results based on number of highlights

Posted by Naresh <nn...@gmail.com>.
Can you omit norms and check?

On Fri, Jan 11, 2013 at 2:25 PM, wwhite1133 <ww...@gmail.com> wrote:

> While reading the lists , I found that overriding similarity to return 1
> for
> tf and idf i a way for this.
> Is that correct or is there any other way ?
> Thanks
> WW
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Sorting-the-search-results-based-on-number-of-highlights-tp4031175p4032452.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 
Regards
Naresh

Re: Sorting the search results based on number of highlights

Posted by wwhite1133 <ww...@gmail.com>.
While reading the lists , I found that overriding similarity to return 1 for
tf and idf i a way for this.
Is that correct or is there any other way ?
Thanks 
WW



--
View this message in context: http://lucene.472066.n3.nabble.com/Sorting-the-search-results-based-on-number-of-highlights-tp4031175p4032452.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Sorting the search results based on number of highlights

Posted by Upayavira <uv...@odoko.co.uk>.
Are you asking to sort on the number of matching terms?

Not an answer, but hopefully giving you pointers...

Firstly, highlighting is done in the highlighting component, which comes
after the QueryComponent in the list of search components invoked.
Sorting happens within the QueryComponent, which therefore cannot make
use of information not yet derived, which makes your request challenging
right from the start.

A sensible way to implement sort here is to implement a function query
(which I think you can do using a ValueSourceParser in 4.0). You can
then sort on that function. So, the question is how can you derive a
numerical value from a document that will represent your sort
preference, before highlighting has actually happened, and how can you
do so quickly enough, given that the value will have to be calculated
for every document matching your query, not just for the ones returned
to your user.

HTH

Upayavira

On Mon, Jan 7, 2013, at 07:27 AM, wwhite1133 wrote:
> Hi ,
>  I wanted to sort the results of the solr search query on the number of
> highlights generated per document. 
> e.g  
> Doc 1 
> highlights {
> fieldA
> FieldB
> }
> Doc 2
> Highlights{
> field A 
> fieldC
> fieldC
> }
> 
> No, I understand that score is calculated depending on many factors like
> ,
> tf , idf boost etc. So when I sort on score the the document with 2
> highlights can come ahead of the document with 3 highlights.
> How can I sort based on purely the number of highlights. 
> Right now I am doing it in the code but 
> I do not want to do this in code  as then the pagination becomes an issue
> .
> I have to fetch a larger number of records and do in memory sorting . 
> 
> Any help is appreciated.
> Thanks 
> WW
> 
> 
> 
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Sorting-the-search-results-based-on-number-of-highlights-tp4031175.html
> Sent from the Solr - User mailing list archive at Nabble.com.