The problem is: Lucene has never supported *real* per-document boosts. Those boosts were always per-field. As we only work per-field, it depends on the query how your results score. If you have a TermQuery, the per-field boost is used (the one from the field queried), but e.g. if you have another query (like MultiTermQuery) the boost is ignored completely. As it is always per-field, the results of this per-document boosting differ depending on the number of terms in your query, so it is not easy to make it consistent. To boost a document in Lucene 1.x, 2.x, 3.x, and also 4.x, you have to use a function query with a per-document value that you have indexed as a separate (ideally as docvalues) field. In previous Lucene versions, FieldCache was the way to go. This code is a simple wrapper around your query with CustomScoreQuery and a ValueSource referring to the DocValues field, 5 lines of code -> and it will return consistent results!
Uwe ----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: u...@thetaphi.de > -----Original Message----- > From: Paul Taylor [mailto:paul_t...@fastmail.fm] > Sent: Monday, February 18, 2013 5:08 PM > To: Uwe Schindler > Cc: java-user@lucene.apache.org > Subject: Re: What is equivalent to Document.setBoost() from Lucene 3.6 > inLucene 4.1 ? > > On 18/02/2013 16:04, Uwe Schindler wrote: > > It is not a regression, as per-Document boost were never working correctly. > If you want to boost documents in a consistent way (and make their scores in > search results really using that factor), you should index a DocValues field > and use that in a CustomScoreQuery to boost the results with that docvalues > field. In Lucene 4.0 (together with other changes) we dropped the "old- > style", confusing, and incorrect feature. > Well per-Document boost seemed to worked for me with my tests. This new > method your propose sounds more complex and is different to what the > migration guide says so I don't see that as an improvement. > > Paul > > ----- > > Uwe Schindler > > H.-H.-Meier-Allee 63, D-28213 Bremen > > http://www.thetaphi.de > > eMail: u...@thetaphi.de > > > > > >> -----Original Message----- > >> From: Paul Taylor [mailto:paul_t...@fastmail.fm] > >> Sent: Monday, February 18, 2013 4:54 PM > >> To: Ian Lea > >> Cc: java-user@lucene.apache.org > >> Subject: Re: What is equivalent to Document.setBoost() from Lucene > >> 3.6 inLucene 4.1 ? > >> > >> On 18/02/2013 13:41, Ian Lea wrote: > >>> See the migration guide: > >>> > >>> "If you previously used Document.setBoost, you must now pre-multiply > >>> the document boost into each Field.setBoost. If you have a > >>> multi-valued field, you should do this only for the first Field > >>> instance (ie, subsequent Field instance sharing the same field name > >>> should only include their per-field boost and not the document level > >>> boost) as the boost for multi-valued field instances are multiplied > >>> together by Lucene." > >>> > >>> > >>> -- > >>> Ian. > >>> > >>> > >>> On Mon, Feb 18, 2013 at 12:17 PM, Paul Taylor > >>> <paul_t...@fastmail.fm> > >> wrote: > >>>> What is equivalent to Document.setBoost() from Lucene 3.6 inLucene > >>>> 4.1 > >> ? > >>>> ------------------------------------------------------------------- > >>>> -- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > >>>> For additional commands, e-mail: java-user-h...@lucene.apache.org > >>>> > >> Thanks, so its more difficult now sounds like a regression to me. > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > >> For additional commands, e-mail: java-user-h...@lucene.apache.org > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org