lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: NumericRangeQuery: what am I doing wrong?
Date Wed, 14 Dec 2011 19:04:46 GMT
Hmmm, seems like it should work, but there are two things you might try:
1> just execute the query in Solr. id:1 TO 1000000]. Does that work?
2> I'm really grasping at straws here, but it's *possible* that you
     need to use the same precisionstep as tint (8?)? There's a
     constructor that takes precisionStep as a parameter, but the
     default is 4 in the 3.x code.

I guess it's also possible that you're not really connecting to the
server you think you are, but I doubt it as I expect your unit test
is creating the index for you, in which case you can't do <1>....

Best
Erick

On Wed, Dec 14, 2011 at 12:14 PM, Dmitry Kan <dmitry.kan@gmail.com> wrote:
> Maybe you should index your values differently? Here is what Lucene's 2.9
> javadoc says:
>
> To use this, you must first index the numeric values using
> NumericField<http://lucene.apache.org/java/2_9_0/api/all/org/apache/lucene/document/NumericField.html>(expert:
> NumericTokenStream<http://lucene.apache.org/java/2_9_0/api/all/org/apache/lucene/analysis/NumericTokenStream.html>).
> If your terms are instead textual, you should use
> TermRangeQuery<http://lucene.apache.org/java/2_9_0/api/all/org/apache/lucene/search/TermRangeQuery.html>.
> NumericRangeFilter<http://lucene.apache.org/java/2_9_0/api/all/org/apache/lucene/search/NumericRangeFilter.html>is
> the filter equivalent of this query.
>
> Dmitry
>
> On Wed, Dec 14, 2011 at 6:53 PM, Jay Luker <lbjay@reallywow.com> wrote:
>
>> I can't get NumericRangeQuery or TermQuery to work on my integer "id"
>> field. I feel like I must be missing something obvious.
>>
>> I have a test index that has only two documents, id:9076628 and
>> id:8003001. The id field is defined like so:
>>
>> <field name="id" type="tint" indexed="true" stored="true" required="true"
>> />
>>
>> A MatchAllDocsQuery will return the 2 documents, but any queries I try
>> on the id field return no results. For instance,
>>
>> public void testIdRange() throws IOException {
>>    Query q = NumericRangeQuery.newIntRange("id", 1, 10000000, true, true);
>>    System.out.println("query: " + q);
>>    assertEquals(2, searcher.search(q, 5).totalHits);
>> }
>>
>> public void testIdSearch() throws IOException {
>>    Query q = new TermQuery(new Term("id", "9076628"));
>>    System.out.println("query: " + q);
>>    assertEquals(1, searcher.search(q, 5).totalHits);
>> }
>>
>> Both tests fail with totalHits being 0. This is using solr/lucene
>> trunk, but I tried also with 3.2 and got the same results.
>>
>> What could I be doing wrong here?
>>
>> Thanks,
>> --jay
>>

Mime
View raw message