I have an old test case I'm dusting off. I've moved up to Search 420 with Lucene core 3.6.2 jars. The .class files and lucene index files are completely recreated each time the test case runs so I'm not using old files by mistake.
My test case fails because a query returns 0 results. Other test cases for non-Numeric fields work fine, it's just @NumericField queries that are failing.
It also fails in Luke, which I'll concentrate on here because it removes my test case code from the situation. I cannot query for "cc:7" in an index where I can see there certainly is a Document with a 'cc' field of value 7.
My test entity has a 'cc' field:
Code:
@Entity(name="bikes")
@Table(name="bike_items")
@Indexed
public class BikeEntity extends ItemEntity {
[cut]
@Column(nullable=false)
@Field(index=Index.YES, analyze=Analyze.NO, store=Store.YES)
@NumericField
@Analyzer(impl=org.apache.lucene.analysis.standard.StandardAnalyzer.class)
private Integer cc;
My test case creates a Hibernate Search connection and creates 10 entities each with a different value for 'cc'. Running Luke 3.5.0 I can see 'cc' in the list of fields in the Overview, and going to Documents I can see that most documents have a 'cc' field like this:
Code:
Field IdfpTSVopNLB# Norm Value
cc Id--TS------# --- 7
So the field is Indexed, Tokenized (which I think would have no effect on my problem?), Stored (irrelevant but handy to see in the index while debugging) and Numeric (so string padding with zeroes etc. isn't relevant).
In the Search pane of Luke, the Analyzer is set to StandardAnalyzer and a search of "cc:7" returns no results. This should return 1 result.
If I enable "Allow leading * in wildcard queries" and search for "cc:*" I do get a full list of documents, including the one with cc=7.
I've tried specifying the @Analyzer annotation as SimpleAnalyzer, with similar change in Luke to set the analyzer used during Search, but it didn't help. Also tried leaving the @Analyzer out entirely, still no help.
Does anything here seem amiss? I've been scratching my head for a while. I don't feel that writing a bunch of Java code to directly interrogate the index would help, if even Luke cannot return results.
Nick