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

Reply via email to