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 S Eslamian <se...@gmail.com> on 2011/09/13 09:22:03 UTC

use QueryTermExtractor for RangeQueries

Hi
I am using QueryTermExtractor.getTerms for finding the terms of a given
query in lucene 3.0.3. In it's document has said that "Utility class used to
extract the terms used in a query, plus any weights. This class will not
find terms for MultiTermQuery, RangeQuery and PrefixQuery classes so the
caller must pass a rewritten query (see Query.rewrite) to obtain a list of
expanded terms.", but for these queries - MultiTermQuery, RangeQuery and
PrefixQuery - even rewritten query, it doesn't return the correct list of
expanded terms.
What should I do? For example for e PrefixQuery like 'hell*' it returns
'hell*' instead of " 'hell' and 'hello' and ... ";

Re: use QueryTermExtractor for RangeQueries

Posted by Simon Willnauer <si...@googlemail.com>.
On Sat, Sep 17, 2011 at 7:19 AM, S Eslamian <se...@gmail.com> wrote:
> ofcourse I do this. This is my sample cod to get terms:
>
>
> PrefixQuery pq = new PrefixQuery(new Term("field","hell*"));
> rewritenQuery = indexSearcher.rewrite(pq);
> QueryTermExtractor qte = new QueryTermExtractor();
> WeightedTerm[] wt = qte.getTerms(rewritenQuery );
>
> and it returns nothing to me in wt!!!

hmm, (I have to admit I never used QueryTermExtractor) maybe there is
no term in the index starting with "hell*" maybe they start with
"hell" ?
you don't need the asterisk when you create the prefix query directly, no?

simon
>
> On Thu, Sep 15, 2011 at 12:36 PM, Simon Willnauer
> <si...@googlemail.com> wrote:
>>
>> Hey,
>>
>> do you use the query you passed to rewrite to extract the terms or the
>> query returned from rewrite?
>>
>> you should do it like this:
>>
>> Query q = ...
>>
>> q = indexSearcher.rewrite(q);
>>
>> ...
>>
>> simon
>>
>> On Thu, Sep 15, 2011 at 6:02 AM, S Eslamian <se...@gmail.com> wrote:
>> > I have an instance of IndexSearcher and then call rewrite method with
>> > the
>> > query.
>> > IndexRear ir = IndexReader.open("directory path",true);
>> > IndexSearcher indexSearcher = new IndexSearcher(ir);
>> > indexSearcher.rewrite(query);
>> >
>> >
>> > On Wed, Sep 14, 2011 at 10:03 PM, Simon Willnauer
>> > <si...@googlemail.com> wrote:
>> >>
>> >> how do you rewrite your query?
>> >>
>> >> simon
>> >>
>> >> On Tue, Sep 13, 2011 at 9:22 AM, S Eslamian <se...@gmail.com>
>> >> wrote:
>> >> > Hi
>> >> > I am using QueryTermExtractor.getTerms for finding the terms of a
>> >> > given
>> >> > query in lucene 3.0.3. In it's document has said that "Utility class
>> >> > used to
>> >> > extract the terms used in a query, plus any weights. This class will
>> >> > not
>> >> > find terms for MultiTermQuery, RangeQuery and PrefixQuery classes so
>> >> > the
>> >> > caller must pass a rewritten query (see Query.rewrite) to obtain a
>> >> > list
>> >> > of
>> >> > expanded terms.", but for these queries - MultiTermQuery, RangeQuery
>> >> > and
>> >> > PrefixQuery - even rewritten query, it doesn't return the correct
>> >> > list
>> >> > of
>> >> > expanded terms.
>> >> > What should I do? For example for e PrefixQuery like 'hell*' it
>> >> > returns
>> >> > 'hell*' instead of " 'hell' and 'hello' and ... ";
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> 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: use QueryTermExtractor for RangeQueries

Posted by S Eslamian <se...@gmail.com>.
ofcourse I do this. This is my sample cod to get terms:


PrefixQuery pq = new PrefixQuery(new Term("field","hell*"));
rewritenQuery = indexSearcher.rewrite(pq);
QueryTermExtractor qte = new QueryTermExtractor();
WeightedTerm[] wt = qte.getTerms(rewritenQuery );

and it returns nothing to me in wt!!!

On Thu, Sep 15, 2011 at 12:36 PM, Simon Willnauer <
simon.willnauer@googlemail.com> wrote:

> Hey,
>
> do you use the query you passed to rewrite to extract the terms or the
> query returned from rewrite?
>
> you should do it like this:
>
> Query q = ...
>
> q = indexSearcher.rewrite(q);
>
> ...
>
> simon
>
> On Thu, Sep 15, 2011 at 6:02 AM, S Eslamian <se...@gmail.com> wrote:
> > I have an instance of IndexSearcher and then call rewrite method with the
> > query.
> > IndexRear ir = IndexReader.open("directory path",true);
> > IndexSearcher indexSearcher = new IndexSearcher(ir);
> > indexSearcher.rewrite(query);
> >
> >
> > On Wed, Sep 14, 2011 at 10:03 PM, Simon Willnauer
> > <si...@googlemail.com> wrote:
> >>
> >> how do you rewrite your query?
> >>
> >> simon
> >>
> >> On Tue, Sep 13, 2011 at 9:22 AM, S Eslamian <se...@gmail.com>
> wrote:
> >> > Hi
> >> > I am using QueryTermExtractor.getTerms for finding the terms of a
> given
> >> > query in lucene 3.0.3. In it's document has said that "Utility class
> >> > used to
> >> > extract the terms used in a query, plus any weights. This class will
> not
> >> > find terms for MultiTermQuery, RangeQuery and PrefixQuery classes so
> the
> >> > caller must pass a rewritten query (see Query.rewrite) to obtain a
> list
> >> > of
> >> > expanded terms.", but for these queries - MultiTermQuery, RangeQuery
> and
> >> > PrefixQuery - even rewritten query, it doesn't return the correct list
> >> > of
> >> > expanded terms.
> >> > What should I do? For example for e PrefixQuery like 'hell*' it
> returns
> >> > 'hell*' instead of " 'hell' and 'hello' and ... ";
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >> For additional commands, e-mail: java-user-help@lucene.apache.org
> >>
> >
> >
>

Re: use QueryTermExtractor for RangeQueries

Posted by Simon Willnauer <si...@googlemail.com>.
Hey,

do you use the query you passed to rewrite to extract the terms or the
query returned from rewrite?

you should do it like this:

Query q = ...

q = indexSearcher.rewrite(q);

...

simon

On Thu, Sep 15, 2011 at 6:02 AM, S Eslamian <se...@gmail.com> wrote:
> I have an instance of IndexSearcher and then call rewrite method with the
> query.
> IndexRear ir = IndexReader.open("directory path",true);
> IndexSearcher indexSearcher = new IndexSearcher(ir);
> indexSearcher.rewrite(query);
>
>
> On Wed, Sep 14, 2011 at 10:03 PM, Simon Willnauer
> <si...@googlemail.com> wrote:
>>
>> how do you rewrite your query?
>>
>> simon
>>
>> On Tue, Sep 13, 2011 at 9:22 AM, S Eslamian <se...@gmail.com> wrote:
>> > Hi
>> > I am using QueryTermExtractor.getTerms for finding the terms of a given
>> > query in lucene 3.0.3. In it's document has said that "Utility class
>> > used to
>> > extract the terms used in a query, plus any weights. This class will not
>> > find terms for MultiTermQuery, RangeQuery and PrefixQuery classes so the
>> > caller must pass a rewritten query (see Query.rewrite) to obtain a list
>> > of
>> > expanded terms.", but for these queries - MultiTermQuery, RangeQuery and
>> > PrefixQuery - even rewritten query, it doesn't return the correct list
>> > of
>> > expanded terms.
>> > What should I do? For example for e PrefixQuery like 'hell*' it returns
>> > 'hell*' instead of " 'hell' and 'hello' and ... ";
>> >
>>
>> ---------------------------------------------------------------------
>> 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: use QueryTermExtractor for RangeQueries

Posted by S Eslamian <se...@gmail.com>.
I have an instance of IndexSearcher and then call rewrite method with the
query.
IndexRear ir = IndexReader.open("directory path",true);
IndexSearcher indexSearcher = new IndexSearcher(ir);
indexSearcher.rewrite(query);


On Wed, Sep 14, 2011 at 10:03 PM, Simon Willnauer <
simon.willnauer@googlemail.com> wrote:

> how do you rewrite your query?
>
> simon
>
> On Tue, Sep 13, 2011 at 9:22 AM, S Eslamian <se...@gmail.com> wrote:
> > Hi
> > I am using QueryTermExtractor.getTerms for finding the terms of a given
> > query in lucene 3.0.3. In it's document has said that "Utility class used
> to
> > extract the terms used in a query, plus any weights. This class will not
> > find terms for MultiTermQuery, RangeQuery and PrefixQuery classes so the
> > caller must pass a rewritten query (see Query.rewrite) to obtain a list
> of
> > expanded terms.", but for these queries - MultiTermQuery, RangeQuery and
> > PrefixQuery - even rewritten query, it doesn't return the correct list of
> > expanded terms.
> > What should I do? For example for e PrefixQuery like 'hell*' it returns
> > 'hell*' instead of " 'hell' and 'hello' and ... ";
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: use QueryTermExtractor for RangeQueries

Posted by Simon Willnauer <si...@googlemail.com>.
how do you rewrite your query?

simon

On Tue, Sep 13, 2011 at 9:22 AM, S Eslamian <se...@gmail.com> wrote:
> Hi
> I am using QueryTermExtractor.getTerms for finding the terms of a given
> query in lucene 3.0.3. In it's document has said that "Utility class used to
> extract the terms used in a query, plus any weights. This class will not
> find terms for MultiTermQuery, RangeQuery and PrefixQuery classes so the
> caller must pass a rewritten query (see Query.rewrite) to obtain a list of
> expanded terms.", but for these queries - MultiTermQuery, RangeQuery and
> PrefixQuery - even rewritten query, it doesn't return the correct list of
> expanded terms.
> What should I do? For example for e PrefixQuery like 'hell*' it returns
> 'hell*' instead of " 'hell' and 'hello' and ... ";
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org