querying for a string'ed number in lucene finds nothing

I have an existing index with some documents I'm trying to search. When I search a "real textual" field, everything is OK. When I try to search a field which is a number, the search gives 0 results. The code is something like this (it is pylucene but the concept is the same):

dir = SimpleFSDirectory(File(indexDir))
analyzer = StandardAnalyzer(Version.LUCENE_CURRENT)
searcher = IndexSearcher(dir)
query = QueryParser(Version.LUCENE_CURRENT, "id", analyzer).parse("902")
hits = searcher.search(query, MAX)
print hits.totalHits #gives me 0

a luke search (id:902) gives me empty results as well. When I look at the Overview tab on luke it says this field is UTF-8 (string)

Anything I'm doing wrong?

edit: It appears this happens on Fields that are indexed and has no Norm (according to the flags of luke). Can someone explain it?


I don't like answering my own questions but I believe this answer is an important reference. The solution is put a NumericRange query with both numbers the number you seek (this time in java):

NumericRangeQuery.newIntRange("id", Integer.valueOf(902), Integer.valueOf(902),
true, true)     

Are you using SimpleAnalyzer while indexing? It strips off numbers. Make sure you are using same analyzer while indexing and searching.

Need Your Help

Looking for DES algorithm tutorial

algorithm cryptography des

I am studying for cryptography and I somehow stuck on understanding how DES works. Because it is around for a long time there should be nice tutorials like fancy diagrams, videos etc around the net...

What is the point of having both points to and dot operator?

c++ pointers syntax

I know the difference between the points-to (->) and dot (.) operator but I don't see why the need for the two arrises? Isn't it always just as easy not to use pointers and just use the dot operator?