lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Hardiker <dhardi...@adaptavist.com>
Subject Re: Numerical Range Query
Date Mon, 12 May 2008 19:21:01 GMT
Erick Erickson wrote:
> Although I'm a bit puzzled by what you're actually getting back.
> You might try using Luke to look at your index to see what's
> there.

I've looked through with Luke and it doesn't look like much has changed 
between using NumberTools and not. NumberTools definitely does some 
padding which makes sense, however even though I'm using that, Lucene or 
Luke seems to be boiling it down to just the number. I'm not sure which.

> See the NumberTools class for some help here.......
> 
> BTW, at least in Lucene 2.1, the preferred way to go about this
> would be ConstantScoreRangeQuery...

Taking your advice I'm now indexing using:

document.add( new Field(RateUtils.SF_FILTERED_CNT, 
NumberTools.longToString( filteredCount ), Field.Store.YES, 
Field.Index.UN_TOKENIZED) );

and searching using:

I'm now
int minRates = Long.valueOf( minRatesString ).intValue();
luceneQuery.add( new ConstantScoreRangeQuery( RateUtils.SF_FILTERED_CNT, 
NumberTools.longToString(minRates), "", true, false ), 
BooleanClause.Occur.MUST );

I get very odd results back now, but they seem to work similarly. The 
documentation for ConstantScoreRangeQuery is rather thin however I did 
find this example which suggests I'm doing the right thing:

http://github.com/we4tech/semantic-repository/tree/master/development/idea-repository-core/src/main/java/com/ideabase/repository/core/index/ExtendedQueryParser.java

The code _looks_ like it should work, it makes sense logically but it 
still doesn't do what I'm expecting.

I've tried changing the indexing over to Field.Index.NO_NORMS and it 
makes the field value "0000000000000b" instead of "11", and 
"00000000000002" instead of "2" ... but that meant that the searching 
didn't pick up on that field _at all_.

Surely "find me results where numeric field x is higher than y" can't be 
an uncommon request? I can think of many areas where you want to do that 
(age filtering for example).

Any other suggestions of what I should be looking for, or where I can 
look to find out the next step to take?


--
Dan Hardiker

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


Mime
View raw message