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 Adrien Grand <jp...@gmail.com> on 2017/07/06 10:39:13 UTC
Re: SpanMultiTermQueryWrapper issue in lucene 6.6.0
What is the context of this code? Depending whether you are just trying to
consume this query or building a query wrapper, you should either call
searcher.createNormalizedWeight(spt2, true) instead or make sure that your
query wrapper rewrites the wrapped queries.
Le jeu. 6 juil. 2017 à 12:36, Ranganath B N <ra...@huawei.com> a
écrit :
> Hi,
>
> Execution of the following code snippet
> "RegexpQuery regquery= new RegexpQuery(new Term("text",
> "regul.*"));
> spt2 = new SpanMultiTermQueryWrapper<RegexpQuery>(regquery);
> spt2.createWeight(searcher, true);"
>
> throws java.lang.IllegalArgumentException: Rewrite first!
>
>
> Can anyone suggest what is the problem with this?
>
> Thanks,
> Ranganath B. N.
>
>
Re: SpanMultiTermQueryWrapper issue in lucene 6.6.0
Posted by Alan Woodward <al...@flax.co.uk>.
The contract to create a Weight is to repeatedly call rewrite() until the query is no longer changing, and then call createWeight - IndexSearcher.createNormalizedWeight() will do this for you.
Alan Woodward
www.flax.co.uk
> On 6 Jul 2017, at 12:34, Ranganath B N <ra...@huawei.com> wrote:
>
> Thanks Alan. Solution works. But why should we first rewrite?
>
> -----Original Message-----
> From: Alan Woodward [mailto:alan@flax.co.uk]
> Sent: Thursday, July 06, 2017 4:36 PM
> To: java-user@lucene.apache.org
> Cc: Vadiraj Muradi
> Subject: Re: SpanMultiTermQueryWrapper issue in lucene 6.6.0
>
> You need to call SpanNearQuery.rewrite(), and then call createWeight() on the resulting query.
>
> Alan Woodward
> www.flax.co.uk
>
>
>> On 6 Jul 2017, at 11:54, Ranganath B N <ra...@huawei.com> wrote:
>>
>> Hi Adrien,
>>
>> This SpanQuery spt2 will be a component of the SpanQueryarray
>> input to the constructor of the SpanNearQuery object. Then I call
>> SpanNearQuery.createweight(....) which in turn calls
>> SpanMultiTermQueryWrapper.createweight() and the "
>> java.lang.IllegalArgumentException: Rewrite first!" is thrown
>>
>> Thanks,
>> Ranganath B. N.
>>
>>
>>
>> -----Original Message-----
>> From: Adrien Grand [mailto:jpountz@gmail.com]
>> Sent: Thursday, July 06, 2017 4:09 PM
>> To: java-user@lucene.apache.org
>> Cc: Vadiraj Muradi
>> Subject: Re: SpanMultiTermQueryWrapper issue in lucene 6.6.0
>>
>> What is the context of this code? Depending whether you are just trying to consume this query or building a query wrapper, you should either call searcher.createNormalizedWeight(spt2, true) instead or make sure that your query wrapper rewrites the wrapped queries.
>>
>> Le jeu. 6 juil. 2017 à 12:36, Ranganath B N <ra...@huawei.com> a écrit :
>>
>>> Hi,
>>>
>>> Execution of the following code snippet
>>> "RegexpQuery regquery= new RegexpQuery(new Term("text",
>>> "regul.*"));
>>> spt2 = new SpanMultiTermQueryWrapper<RegexpQuery>(regquery);
>>> spt2.createWeight(searcher, true);"
>>>
>>> throws java.lang.IllegalArgumentException: Rewrite first!
>>>
>>>
>>> Can anyone suggest what is the problem with this?
>>>
>>> Thanks,
>>> Ranganath B. N.
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
RE: SpanMultiTermQueryWrapper issue in lucene 6.6.0
Posted by Ranganath B N <ra...@huawei.com>.
Thanks Alan. Solution works. But why should we first rewrite?
-----Original Message-----
From: Alan Woodward [mailto:alan@flax.co.uk]
Sent: Thursday, July 06, 2017 4:36 PM
To: java-user@lucene.apache.org
Cc: Vadiraj Muradi
Subject: Re: SpanMultiTermQueryWrapper issue in lucene 6.6.0
You need to call SpanNearQuery.rewrite(), and then call createWeight() on the resulting query.
Alan Woodward
www.flax.co.uk
> On 6 Jul 2017, at 11:54, Ranganath B N <ra...@huawei.com> wrote:
>
> Hi Adrien,
>
> This SpanQuery spt2 will be a component of the SpanQueryarray
> input to the constructor of the SpanNearQuery object. Then I call
> SpanNearQuery.createweight(....) which in turn calls
> SpanMultiTermQueryWrapper.createweight() and the "
> java.lang.IllegalArgumentException: Rewrite first!" is thrown
>
> Thanks,
> Ranganath B. N.
>
>
>
> -----Original Message-----
> From: Adrien Grand [mailto:jpountz@gmail.com]
> Sent: Thursday, July 06, 2017 4:09 PM
> To: java-user@lucene.apache.org
> Cc: Vadiraj Muradi
> Subject: Re: SpanMultiTermQueryWrapper issue in lucene 6.6.0
>
> What is the context of this code? Depending whether you are just trying to consume this query or building a query wrapper, you should either call searcher.createNormalizedWeight(spt2, true) instead or make sure that your query wrapper rewrites the wrapped queries.
>
> Le jeu. 6 juil. 2017 à 12:36, Ranganath B N <ra...@huawei.com> a écrit :
>
>> Hi,
>>
>> Execution of the following code snippet
>> "RegexpQuery regquery= new RegexpQuery(new Term("text",
>> "regul.*"));
>> spt2 = new SpanMultiTermQueryWrapper<RegexpQuery>(regquery);
>> spt2.createWeight(searcher, true);"
>>
>> throws java.lang.IllegalArgumentException: Rewrite first!
>>
>>
>> Can anyone suggest what is the problem with this?
>>
>> Thanks,
>> Ranganath B. N.
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: SpanMultiTermQueryWrapper issue in lucene 6.6.0
Posted by Alan Woodward <al...@flax.co.uk>.
You need to call SpanNearQuery.rewrite(), and then call createWeight() on the resulting query.
Alan Woodward
www.flax.co.uk
> On 6 Jul 2017, at 11:54, Ranganath B N <ra...@huawei.com> wrote:
>
> Hi Adrien,
>
> This SpanQuery spt2 will be a component of the SpanQueryarray input to the constructor of the SpanNearQuery object. Then I call SpanNearQuery.createweight(....) which in turn calls
> SpanMultiTermQueryWrapper.createweight() and the " java.lang.IllegalArgumentException: Rewrite first!" is thrown
>
> Thanks,
> Ranganath B. N.
>
>
>
> -----Original Message-----
> From: Adrien Grand [mailto:jpountz@gmail.com]
> Sent: Thursday, July 06, 2017 4:09 PM
> To: java-user@lucene.apache.org
> Cc: Vadiraj Muradi
> Subject: Re: SpanMultiTermQueryWrapper issue in lucene 6.6.0
>
> What is the context of this code? Depending whether you are just trying to consume this query or building a query wrapper, you should either call searcher.createNormalizedWeight(spt2, true) instead or make sure that your query wrapper rewrites the wrapped queries.
>
> Le jeu. 6 juil. 2017 à 12:36, Ranganath B N <ra...@huawei.com> a écrit :
>
>> Hi,
>>
>> Execution of the following code snippet
>> "RegexpQuery regquery= new RegexpQuery(new Term("text",
>> "regul.*"));
>> spt2 = new SpanMultiTermQueryWrapper<RegexpQuery>(regquery);
>> spt2.createWeight(searcher, true);"
>>
>> throws java.lang.IllegalArgumentException: Rewrite first!
>>
>>
>> Can anyone suggest what is the problem with this?
>>
>> Thanks,
>> Ranganath B. N.
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
RE: SpanMultiTermQueryWrapper issue in lucene 6.6.0
Posted by Ranganath B N <ra...@huawei.com>.
Hi Adrien,
This SpanQuery spt2 will be a component of the SpanQueryarray input to the constructor of the SpanNearQuery object. Then I call SpanNearQuery.createweight(....) which in turn calls
SpanMultiTermQueryWrapper.createweight() and the " java.lang.IllegalArgumentException: Rewrite first!" is thrown
Thanks,
Ranganath B. N.
-----Original Message-----
From: Adrien Grand [mailto:jpountz@gmail.com]
Sent: Thursday, July 06, 2017 4:09 PM
To: java-user@lucene.apache.org
Cc: Vadiraj Muradi
Subject: Re: SpanMultiTermQueryWrapper issue in lucene 6.6.0
What is the context of this code? Depending whether you are just trying to consume this query or building a query wrapper, you should either call searcher.createNormalizedWeight(spt2, true) instead or make sure that your query wrapper rewrites the wrapped queries.
Le jeu. 6 juil. 2017 à 12:36, Ranganath B N <ra...@huawei.com> a écrit :
> Hi,
>
> Execution of the following code snippet
> "RegexpQuery regquery= new RegexpQuery(new Term("text",
> "regul.*"));
> spt2 = new SpanMultiTermQueryWrapper<RegexpQuery>(regquery);
> spt2.createWeight(searcher, true);"
>
> throws java.lang.IllegalArgumentException: Rewrite first!
>
>
> Can anyone suggest what is the problem with this?
>
> Thanks,
> Ranganath B. N.
>
>