0
我正在使用apache lucene在我的應用程序中執行全文搜索。現在我必須執行一個範圍查詢來搜索兩個整數之間的記錄。如何在apache lucene中執行整數範圍查詢?
我已經使用以下代碼
private void set(String fieldName, String fieldValue, Document luceneDocument, LuceneOptions options, Float boost) {
if (fieldName != null && fieldValue != null) {
Field luceneField =
new Field(fieldName,
fieldValue.toLowerCase(),
options.getStore(),
options.getIndex(),
options.getTermVector());
luceneField.setBoost(boost);
luceneDocument.add(luceneField);
}
}
上述方法創建用於我的字段名「大小」,其可能的值是在-999至9999之間的範圍內正的和負整數Lucene索引創建了索引
現在,如果我創建了一個lucene範圍查詢,如(幅度:[10至345])或(幅度:[10至null])。我沒有得到正確的記錄數。
可能的重複[如何使Lucene中的QueryParser處理數字範圍?](http://stackoverflow.com/questions/5026185/how-do-i-make-the-queryparser-in-lucene-handle -numeric-範圍) – femtoRgon 2014-11-24 16:51:50