lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Uwe Schindler <...@thetaphi.de>
Subject Re: my rangequery problem
Date Wed, 30 May 2012 11:33:27 GMT
You don't need to rewrite queries, its automatically done inside Lucene's search logic, just
run the query with IndexSearcher.search. To what Lucene rewrites queries is internal and can
change at any time.

So what is the problem?
--
Uwe Schindler
H.-H.-Meier-Allee 63, 28213 Bremen
http://www.thetaphi.de



S Eslamian <seslamian@gmail.com> schrieb:

Thanks Ian for your answer. I'm using lucene 3.5. Let me say from the
beginning :

I've written a MyParser class which extends MultiFieldQueryParser. And then
override the getRangeQuery method. In this method I call
NumericRangeQuery.newIntRange for receiving the query.
Then in my main method, I have a query like this : "field : [10 TO 20]".
I call MyParser.parse with that query, then after receiving the parsed
query, I call rewrite method :

QueryParser qp = new MyQueryPrser (version,fields[],analyzer);
Query q = qp.parse("field : [10 TO 20]");
IndesSearcher is = new
IndexSearcher(IndexReader.open(NIOFSDirectory.open(new File("Index
Address"))));
Query rewrittenQuery = is.rewrite(q);

The rewrittenQuery in some ranges is wrong and has a strange value!

On Wed, May 30, 2012 at 1:58 PM, Ian Lea <ian.lea@gmail.com> wrote:

> Do you mean NumericRangeQuery or a textual range query that happens to
> be searching on numbers?
>
> What exactly is wrong?
>
> The rewrite method (are you calling this yourself? why?) does indeed
> mess around with queries and some may end up wrapped with
> ConstantScoreQuery. I can't remember what happens with range queries
> by default. I think they end up as a MultiTermQuery, The javadocs
> for that have a note about rewrite and constant scoring.
>
> Finally, what version of lucene are you using?
>
>
> --
> Ian.
>
>
> On Wed, May 30, 2012 at 6:55 AM, S Eslamian <seslamian@gmail.com> wrote:
> > Hi all.
> > I'm searching numericRangeQuery in my indexes. (i.e. field : [10 TO 20])
> > In some ranges when I rewrite the query, I receive something wrong in the
> > answer. something like this : ConstantSocre(field : `
> > When I expand the range, then everything is OK. I debug the code and this
> > wrong answer comes from rewrite(IndexReader reader) method in
> > MultiTermQuery class.
> > I know it should be a problem in my index. But I can't understand what it
> > may be!
> > Can anyone help me?
>
>_____________________________________________

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


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message