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....@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 <seslam...@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-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>

Reply via email to