Mailing List Archive

NumericRangeQuery in Lucene 5.5.5: replacing the deprecated setBoost while keeping the NumericRange type?
Hi.

We are using Lucene 5.5.5 where setBoost is deprecated for all Query types.
How to set the boost of a NumericRangeQuery while preserving the
NumericRangeQuery type?
BoostQuery doesn't allow this and I haven't found a way.

Thanks for your help.

Claude Lepère
Re: NumericRangeQuery in Lucene 5.5.5: replacing the deprecated setBoost while keeping the NumericRange type? [ In reply to ]
Hello Claude,
Wrap it by BoostQuery. see https://lucene.apache.org/core/6_0_0/MIGRATE.html


On Sat, Nov 25, 2023 at 2:46?PM Claude Lepère <claudelepere@gmail.com>
wrote:

> Hi.
>
> We are using Lucene 5.5.5 where setBoost is deprecated for all Query types.
> How to set the boost of a NumericRangeQuery while preserving the
> NumericRangeQuery type?
> BoostQuery doesn't allow this and I haven't found a way.
>
> Thanks for your help.
>
> Claude Lepère
>


--
Sincerely yours
Mikhail Khludnev
Re: NumericRangeQuery in Lucene 5.5.5: replacing the deprecated setBoost while keeping the NumericRange type? [ In reply to ]
Hello Mikhail.

Sorry if I was not precise enough.
A NumericRangeQuery can be wrapped in a BooleanQuery with a boost but this
boost is applied to the BoostQuery (a Query) not to the wrapped
NumericRangeQuery.
Casting BoostQuery or Query to NumericRangeQuery is impossible and
BoostQuery.getQuery returns the wrapped NumericRangeQuery not modified, not
boosted (by virtue of immutability? The migration guide does not say that
NumericRangeQuery is immutable.).

But my problem is indeed boosting the NumericRangeQuery and I'm staying
with the deprecated NumericRangeQuery.setBoost.

Thanks for your help.

Claude Lepère






On Sat, Nov 25, 2023 at 3:14?PM Mikhail Khludnev <mkhl@apache.org> wrote:

> Hello Claude,
> Wrap it by BoostQuery. see
> https://lucene.apache.org/core/6_0_0/MIGRATE.html
>
>
> On Sat, Nov 25, 2023 at 2:46?PM Claude Lepère <claudelepere@gmail.com>
> wrote:
>
> > Hi.
> >
> > We are using Lucene 5.5.5 where setBoost is deprecated for all Query
> types.
> > How to set the boost of a NumericRangeQuery while preserving the
> > NumericRangeQuery type?
> > BoostQuery doesn't allow this and I haven't found a way.
> >
> > Thanks for your help.
> >
> > Claude Lepère
> >
>
>
> --
> Sincerely yours
> Mikhail Khludnev
>
Re: NumericRangeQuery in Lucene 5.5.5: replacing the deprecated setBoost while keeping the NumericRange type? [ In reply to ]
Hi,

Lucene 5 removed the way to boost queries on its own. You have to live
with that. In addition, all queries should be immutable Not yet enfocred
in Lucene 5), which is required for caching purposes*).

When you apply a BoostQuery on top of any other query the scores the
inner query return are just multiplied by the boost. Of course the
original query won't change. That is the typical "wrapper pattern".

I don't understand what you problem is, why do you want to cast those
queries to something they aren't?

Uwe

*) In Lucene 5 not all queries are yet really immutable, but most of
them were changed or setters deprecated. E.g., BooleanQuery has a
builder in 5.5, with all constructors deprecated. The reason for this is
also immutablility: It should be impossible to change the clauses after
constructing the query, so a builder is needed.

Am 25.11.2023 um 16:02 schrieb Claude Lepère:
> Hello Mikhail.
>
> Sorry if I was not precise enough.
> A NumericRangeQuery can be wrapped in a BooleanQuery with a boost but this
> boost is applied to the BoostQuery (a Query) not to the wrapped
> NumericRangeQuery.
> Casting BoostQuery or Query to NumericRangeQuery is impossible and
> BoostQuery.getQuery returns the wrapped NumericRangeQuery not modified, not
> boosted (by virtue of immutability? The migration guide does not say that
> NumericRangeQuery is immutable.).
>
> But my problem is indeed boosting the NumericRangeQuery and I'm staying
> with the deprecated NumericRangeQuery.setBoost.
>
> Thanks for your help.
>
> Claude Lepère
>
>
>
>
>
>
> On Sat, Nov 25, 2023 at 3:14?PM Mikhail Khludnev <mkhl@apache.org> wrote:
>
>> Hello Claude,
>> Wrap it by BoostQuery. see
>> https://lucene.apache.org/core/6_0_0/MIGRATE.html
>>
>>
>> On Sat, Nov 25, 2023 at 2:46?PM Claude Lepère <claudelepere@gmail.com>
>> wrote:
>>
>>> Hi.
>>>
>>> We are using Lucene 5.5.5 where setBoost is deprecated for all Query
>> types.
>>> How to set the boost of a NumericRangeQuery while preserving the
>>> NumericRangeQuery type?
>>> BoostQuery doesn't allow this and I haven't found a way.
>>>
>>> Thanks for your help.
>>>
>>> Claude Lepère
>>>
>>
>> --
>> Sincerely yours
>> Mikhail Khludnev
>>
--
Uwe Schindler
Achterdiek 19, D-28357 Bremen
https://www.thetaphi.de
eMail: uwe@thetaphi.de


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: NumericRangeQuery in Lucene 5.5.5: replacing the deprecated setBoost while keeping the NumericRange type? [ In reply to ]
Hello Uwe.

Many thanks for your reply.
We thought this would be the explanation.

We are using an external imported method that has a NumericRangeQuery as
input parameter.
The NumericRangeQuery is part of a complex BooleanQuery built from the user
input and we would be able to change its default boost (defined in a Field
enum) if the user requires another one.
In the Field enum itself, we can set a new boost - the hardcoded one is not
changed - but the RMI tests show that, on the server side, the boost is
still the default and not the new one.
Our architecture is a bit complicated, it was working with the deprecated
setBoost and we wanted to keep modifications to a minimum.
It's clear we will have to change.


Claude Lepère

On Sun, Nov 26, 2023 at 12:03?PM Uwe Schindler <uwe@thetaphi.de> wrote:

> Hi,
>
> Lucene 5 removed the way to boost queries on its own. You have to live
> with that. In addition, all queries should be immutable Not yet enfocred
> in Lucene 5), which is required for caching purposes*).
>
> When you apply a BoostQuery on top of any other query the scores the
> inner query return are just multiplied by the boost. Of course the
> original query won't change. That is the typical "wrapper pattern".
>
> I don't understand what you problem is, why do you want to cast those
> queries to something they aren't?
>
> Uwe
>
> *) In Lucene 5 not all queries are yet really immutable, but most of
> them were changed or setters deprecated. E.g., BooleanQuery has a
> builder in 5.5, with all constructors deprecated. The reason for this is
> also immutablility: It should be impossible to change the clauses after
> constructing the query, so a builder is needed.
>
> Am 25.11.2023 um 16:02 schrieb Claude Lepère:
> > Hello Mikhail.
> >
> > Sorry if I was not precise enough.
> > A NumericRangeQuery can be wrapped in a BooleanQuery with a boost but
> this
> > boost is applied to the BoostQuery (a Query) not to the wrapped
> > NumericRangeQuery.
> > Casting BoostQuery or Query to NumericRangeQuery is impossible and
> > BoostQuery.getQuery returns the wrapped NumericRangeQuery not modified,
> not
> > boosted (by virtue of immutability? The migration guide does not say that
> > NumericRangeQuery is immutable.).
> >
> > But my problem is indeed boosting the NumericRangeQuery and I'm staying
> > with the deprecated NumericRangeQuery.setBoost.
> >
> > Thanks for your help.
> >
> > Claude Lepère
> >
> >
> >
> >
> >
> >
> > On Sat, Nov 25, 2023 at 3:14?PM Mikhail Khludnev <mkhl@apache.org>
> wrote:
> >
> >> Hello Claude,
> >> Wrap it by BoostQuery. see
> >> https://lucene.apache.org/core/6_0_0/MIGRATE.html
> >>
> >>
> >> On Sat, Nov 25, 2023 at 2:46?PM Claude Lepère <claudelepere@gmail.com>
> >> wrote:
> >>
> >>> Hi.
> >>>
> >>> We are using Lucene 5.5.5 where setBoost is deprecated for all Query
> >> types.
> >>> How to set the boost of a NumericRangeQuery while preserving the
> >>> NumericRangeQuery type?
> >>> BoostQuery doesn't allow this and I haven't found a way.
> >>>
> >>> Thanks for your help.
> >>>
> >>> Claude Lepère
> >>>
> >>
> >> --
> >> Sincerely yours
> >> Mikhail Khludnev
> >>
> --
> Uwe Schindler
> Achterdiek 19, D-28357 Bremen
> https://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>