Many thanks for the replies.

Intuitively, I was hoping that this could be done with a single query class
especially since ConstantScoreQuery seems to be made for that. I've seen
the pattern of wrapping a BoostQuery around a ConstantScoreQuery but this
seemed to me like a workaround. Anyways, I understand that finally this is
a well adopted pattern so I am not going to insist more on this.

Best,
Stamatis

On Mon, Dec 9, 2019 at 10:50 AM Uwe Schindler <u...@thetaphi.de> wrote:

> Hi,
>
> Just add a BoostQuery  with a boost factor of 0.5 around the
> ConstantScoreQuery. It's just one line more in your code. I don't
> understand why we would need separate query classes for this.
>
> Uwe
>
> -----
> Uwe Schindler
> Achterdiek 19, D-28357 Bremen
> https://www.thetaphi.de
> eMail: u...@thetaphi.de
>
> > -----Original Message-----
> > From: Stamatis Zampetakis <zabe...@gmail.com>
> > Sent: Monday, December 9, 2019 10:42 AM
> > To: java-user@lucene.apache.org
> > Subject: Re: Use custom score in ConstantScoreQuery
> >
> > Thanks for you reply Adrien!
> > Can you clarify what is the second way?
> > At the moment I haven't found a way (apart from creating my own Query
> > classes) to say that a query will always return a score of 0.5 for each
> > document.
> >
> > On Mon, Dec 9, 2019 at 8:16 AM Adrien Grand <jpou...@gmail.com> wrote:
> >
> > > Hi Stamatis,
> > >
> > > I personally like the current way things work. If we added the ability
> > > to set a custom score on ConstantScoreQuery, then we'd end up with two
> > > ways to do the same thing, which I like to avoid whenever possible.
> > >
> > > On Sun, Dec 8, 2019 at 10:07 PM Stamatis Zampetakis
> > <zabe...@gmail.com>
> > > wrote:
> > > >
> > > > Small reminder. Any input on this?
> > > >
> > > > Thanks,
> > > > Stamatis
> > > >
> > > > On Mon, Dec 2, 2019 at 12:10 PM Stamatis Zampetakis
> > <zabe...@gmail.com>
> > > > wrote:
> > > >
> > > > > Hi all,
> > > > >
> > > > > Currently ConstantScoreQuery [1] returns a constant score equal to
> 1
> > > for
> > > > > every document that matches the query.
> > > > >
> > > > > I would like to use the ConstantScoreQuery but with a different
> score
> > > > > value that I can pass explicitly (via the constructor for
> instance).
> > > > >
> > > > > This change may also benefit some other parts of Lucene where a
> > > > > ConstantScoreQuery is wrapped around a BoostQuery simply for
> > returning
> > > a
> > > > > score of zero [2][3].
> > > > >
> > > > > Does this change make sense? Shall I create a JIRA for it?
> > > > >
> > > > > Best,
> > > > > Stamatis
> > > > >
> > > > > [1]
> > > > >
> > > https://github.com/apache/lucene-
> > solr/blob/master/lucene/core/src/java/org/apache/lucene/search/Constant
> > ScoreQuery.java
> > > > > [2]
> > > > >
> > > https://github.com/apache/lucene-
> > solr/blob/1d238c844e45f088a942aec14750c186c7a66d92/lucene/core/src/ja
> > va/org/apache/lucene/search/BooleanQuery.java#L253
> > > > > [3]
> > > > >
> > > https://github.com/apache/lucene-
> > solr/blob/1d238c844e45f088a942aec14750c186c7a66d92/lucene/core/src/ja
> > va/org/apache/lucene/search/BoostQuery.java#L97
> > > > >
> > >
> > >
> > >
> > > --
> > > Adrien
> > >
> > > ---------------------------------------------------------------------
> > > 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
>
>

Reply via email to