You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Humberto Rocha <hu...@gmail.com> on 2016/11/10 01:31:34 UTC
Migrate BooleanQuery Lucene 4.9.0 to Lucene 6.0.3
Hi,
In Lucene 4.9.0 i have:
QueryParser parser = new QueryParser("contents",analisador);
Query query = parser.parse(parametro);
BooleanQuery constrainedQuery = new BooleanQuery();
BooleanQuery inner = new BooleanQuery();
inner.add(ownerQueryX, Occur.SHOULD);
inner.add(groupQueryY, Occur.SHOULD);
constrainedQuery.add(inner, Occur.MUST);
constrainedQuery.add(query, Occur.MUST);
How migrate this to Lucene 6.0.3?
I saw BooleanQuery.Builder
<https://lucene.apache.org/core/6_3_0/core/org/apache/lucene/search/BooleanQuery.Builder.html>
but
i have problems to use.
Could someone help me please?
--
Humberto Rocha
Re: Migrate BooleanQuery Lucene 4.9.0 to Lucene 6.0.3
Posted by Humberto Rocha <hu...@gmail.com>.
Oliver,
worked perfectly!
Thanks a lot !
Best regards,
Humberto
On Thu, Nov 10, 2016 at 8:37 AM, Oliver Kaleske <Oliver.Kaleske@ptvgroup.com
> wrote:
> Hi,
>
> try
> BooleanQuery inner = new BooleanQuery.Builder().add(ownerQueryX,
> Occur.SHOULD).add(groupQueryY, Occur.SHOULD).build();
> BooleanQuery constrainedQuery = new BooleanQuery.Builder().add(inner,
> Occur.MUST).add(query, Occur.MUST).build();
>
> You can also split this into several statements if you prefer (probably a
> good idea if you have more than just those two sub-queries per
> BooleanQuery).
>
> Best regards,
> Oliver
>
>
>
> -----Original Message-----
> From: Humberto Rocha [mailto:humrocha@gmail.com]
> Sent: Thursday, November 10, 2016 2:32 AM
> To: java-user@lucene.apache.org
> Subject: Migrate BooleanQuery Lucene 4.9.0 to Lucene 6.0.3
>
> Hi,
>
> In Lucene 4.9.0 i have:
>
>
> QueryParser parser = new QueryParser("contents",
> analisador);
> Query query = parser.parse(parametro);
>
> BooleanQuery constrainedQuery = new BooleanQuery();
> BooleanQuery inner = new BooleanQuery();
> inner.add(ownerQueryX, Occur.SHOULD);
> inner.add(groupQueryY, Occur.SHOULD);
> constrainedQuery.add(inner, Occur.MUST);
> constrainedQuery.add(query, Occur.MUST);
>
>
> How migrate this to Lucene 6.0.3?
>
> I saw BooleanQuery.Builder
> <https://lucene.apache.org/core/6_3_0/core/org/apache/
> lucene/search/BooleanQuery.Builder.html>
> but
> i have problems to use.
>
> Could someone help me please?
>
> --
> Humberto Rocha
>
--
Humberto Rocha
RE: Migrate BooleanQuery Lucene 4.9.0 to Lucene 6.0.3
Posted by Oliver Kaleske <Ol...@ptvgroup.com>.
Hi,
try
BooleanQuery inner = new BooleanQuery.Builder().add(ownerQueryX, Occur.SHOULD).add(groupQueryY, Occur.SHOULD).build();
BooleanQuery constrainedQuery = new BooleanQuery.Builder().add(inner, Occur.MUST).add(query, Occur.MUST).build();
You can also split this into several statements if you prefer (probably a good idea if you have more than just those two sub-queries per BooleanQuery).
Best regards,
Oliver
-----Original Message-----
From: Humberto Rocha [mailto:humrocha@gmail.com]
Sent: Thursday, November 10, 2016 2:32 AM
To: java-user@lucene.apache.org
Subject: Migrate BooleanQuery Lucene 4.9.0 to Lucene 6.0.3
Hi,
In Lucene 4.9.0 i have:
QueryParser parser = new QueryParser("contents",analisador);
Query query = parser.parse(parametro);
BooleanQuery constrainedQuery = new BooleanQuery();
BooleanQuery inner = new BooleanQuery();
inner.add(ownerQueryX, Occur.SHOULD);
inner.add(groupQueryY, Occur.SHOULD);
constrainedQuery.add(inner, Occur.MUST);
constrainedQuery.add(query, Occur.MUST);
How migrate this to Lucene 6.0.3?
I saw BooleanQuery.Builder
<https://lucene.apache.org/core/6_3_0/core/org/apache/lucene/search/BooleanQuery.Builder.html>
but
i have problems to use.
Could someone help me please?
--
Humberto Rocha