You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by mitu2009 <mu...@gmail.com> on 2009/04/02 04:40:04 UTC

Problem using Lucene RangeQuery

I'm using Rangequery to get all the documents which have amount between say 0
to 2. When i execute the query, Lucene gives me documents which have amount
greater than 2 also...What am i missing here?

Here is my code: 
Term lowerTerm = new Term("amount", minAmount); 
Term upperTerm = new Term("amount", maxAmount);
RangeQuery amountQuery = new RangeQuery(lowerTerm, upperTerm, true);            
finalQuery.Add(amountQuery, BooleanClause.Occur.MUST);

and here is what goes into my index:
doc.Add(new Field("amount", amount.ToString(), Field.Store.YES,
Field.Index.UN_TOKENIZED, Field.TermVector.YES));
 

Thanks.
-- 
View this message in context: http://www.nabble.com/Problem-using-Lucene-RangeQuery-tp22839692p22839692.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.


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


Re: Problem using Lucene RangeQuery

Posted by mitu2009 <mu...@gmail.com>.
thanks for your message...yes,i was able to get this working!

Danil ŢORIN wrote:
> 
> Lucene stores and searches STRINGS
> so range [0..2] may return 0,1,101, ..109, 11, 110, ..119, 12, ....., 2
> prefix and normalize your number, like: 001,002...011,012,, 113, etc,
> if you'll have bigger numbers, put more 0's
> 
> All of these and much more are documented on the wiki, javadocs and so
> on, please read them first.
> 
> On Thu, Apr 2, 2009 at 05:40, mitu2009 <mu...@gmail.com> wrote:
>>
>> I'm using Rangequery to get all the documents which have amount between
>> say 0
>> to 2. When i execute the query, Lucene gives me documents which have
>> amount
>> greater than 2 also...What am i missing here?
>>
>> Here is my code:
>> Term lowerTerm = new Term("amount", minAmount);
>> Term upperTerm = new Term("amount", maxAmount);
>> RangeQuery amountQuery = new RangeQuery(lowerTerm, upperTerm, true);
>> finalQuery.Add(amountQuery, BooleanClause.Occur.MUST);
>>
>> and here is what goes into my index:
>> doc.Add(new Field("amount", amount.ToString(), Field.Store.YES,
>> Field.Index.UN_TOKENIZED, Field.TermVector.YES));
>>
>>
>> Thanks.
>> --
>> View this message in context:
>> http://www.nabble.com/Problem-using-Lucene-RangeQuery-tp22839692p22839692.html
>> Sent from the Lucene - Java Developer mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-dev-help@lucene.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-using-Lucene-RangeQuery-tp22839692p22997951.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.


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


Re: Problem using Lucene RangeQuery

Posted by Danil ŢORIN <to...@gmail.com>.
Lucene stores and searches STRINGS
so range [0..2] may return 0,1,101, ..109, 11, 110, ..119, 12, ....., 2
prefix and normalize your number, like: 001,002...011,012,, 113, etc,
if you'll have bigger numbers, put more 0's

All of these and much more are documented on the wiki, javadocs and so
on, please read them first.

On Thu, Apr 2, 2009 at 05:40, mitu2009 <mu...@gmail.com> wrote:
>
> I'm using Rangequery to get all the documents which have amount between say 0
> to 2. When i execute the query, Lucene gives me documents which have amount
> greater than 2 also...What am i missing here?
>
> Here is my code:
> Term lowerTerm = new Term("amount", minAmount);
> Term upperTerm = new Term("amount", maxAmount);
> RangeQuery amountQuery = new RangeQuery(lowerTerm, upperTerm, true);
> finalQuery.Add(amountQuery, BooleanClause.Occur.MUST);
>
> and here is what goes into my index:
> doc.Add(new Field("amount", amount.ToString(), Field.Store.YES,
> Field.Index.UN_TOKENIZED, Field.TermVector.YES));
>
>
> Thanks.
> --
> View this message in context: http://www.nabble.com/Problem-using-Lucene-RangeQuery-tp22839692p22839692.html
> Sent from the Lucene - Java Developer mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org
>
>

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