lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <>
Subject Re: DisjunctionMaxQuery and custom Sort
Date Fri, 05 Mar 2010 09:42:23 GMT
>From the javadocs for the search with sort method it appears you are calling:

NOTE: this does not compute scores by default; use
IndexSearcher.setDefaultFieldSortScoring(boolean, boolean) to enable

Sounds like you need to call that with at least the first arg set to true.


On Fri, Mar 5, 2010 at 9:13 AM, gabriele renzi <> wrote:
> Hi everyone,
> In our search app we'd perform searches with a DisjunctionMaxQuery
> with code like
>, hits)
> Now we'd like to add a custom sub-sort so that when the search returns
> two documents with the same score they will be ordered by a custom
> field (this is not a boost for two reasons: first,  we already use
> boosting for other goals, second, we may like to add a third level of
> boosting in the future)
> I thought I could just change the former line to something like
>, null, hits, new Sort(SortField.SCORE_FIELD,
> new CustomSortField())
> but I had unexpected results, so I dropped our custom SortField, and
> tried the simple
>, null, hits, new Sort(SortField.SCORE_FIELD))
> which I though should have the same behaviour of our original code:
> yet, a large part of our tests failed because it appears that the
> results are not the same as above.
> So my question is threefold:
> 1. is the last query really not functionally equivalent to the first?
> 2. if not, how would the equivalent be?
> 3. and how can I perform a sub-sorting of the results by relevance
> first and my custom score field later?
> FWIW I am using lucene 2.9.1, java 1.6, OSX 10.6. Thanks in advance
> for any help.
> --
> blog en:
> blog it:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message