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

How to create a button for sensor

java android onclick sensor

I have created a code for my sensor to work, but i wanna to enable and be able to disable it by pressing a button like that:

How to programmatically surf on a web page like a human from Windows application?

c# screen-scraping web-crawler

I need to surf on a web page using a C# window application (with a browser tool on it), and collect information for my data mining project. I need a tool that help me invoke events like click and r...