How do I make the QueryParser in Lucene handle numeric ranges?

前端 未结 5 1117
闹比i
闹比i 2020-12-16 05:43
new QueryParser(.... ).parse (somequery);

it works only for string indexed fields. Say i have a field called count where count is a integer field (

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 06:18

    You need to inherit from QueryParser and override GetRangeQuery(string field, ...). If field is one of your numeric field names, return an instance of NumericRangeQuery, otherwise return base.GetRangeQuery(...).

    There is an example of such an implementation in this thread: http://www.mail-archive.com/java-user@lucene.apache.org/msg29062.html

提交回复
热议问题