我使用下面的代码在ListingId上创建索引
Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
NumericField numberField = new NumericField("Listing_Id", Field.Store.YES, true);
numberField.SetDoubleValue(fieldNumber);// .SetDoubleValue(15, 25, 21, 51, etc. ); // Here fieldNumber I am getting from database
doc.Add(numberField);
这是我在搜索中使用的代码:
string indexFileLocation = Server.MapPath("~/searchindex/");
Lucene.Net.Store.Directory dir = Lucene.Net.Store.FSDirectory.GetDirectory(indexFileLocation,false);
IndexSearcher indexSearcher = new IndexSearcher(dir,true);
NumericRangeQuery query = NumericRangeQuery.NewDoubleRange("Listing_Id", 1, 6, true, true);
var hits = indexSearcher.Search(query);
但我在搜索中没有得到任何结果。