Lucene 6添加IntFields

Lucene 6添加IntFields,lucene,field,Lucene,Field,我是一个完全的Lucene新手,如果这个问题太基本,我很抱歉。谷歌搜索没有帮助。我有一些代码可以将Lucene 2迁移到5。旧代码将文档处理为- Document doc = new Document(); doc.add(new StringField("id", "id1", Field.Store.YES)); doc.add(new IntField("numBooks",10,Field.Store.YES)); ... 新的Lucene不再有IntFields。处理这些问题的最佳方

我是一个完全的Lucene新手,如果这个问题太基本,我很抱歉。谷歌搜索没有帮助。我有一些代码可以将Lucene 2迁移到5。旧代码将文档处理为-

Document doc = new Document();
doc.add(new StringField("id", "id1", Field.Store.YES));
doc.add(new IntField("numBooks",10,Field.Store.YES));
...
新的Lucene不再有IntFields。处理这些问题的最佳方法是什么?有NumericDocValuesField,但没有Field.Store参数。最佳的“字段”类型是什么?

数值字段(如IntField)已被点值字段(如)取代。如文档中所述,如果需要存储实例,则应添加一个单独的实例:

doc.add(new IntPoint("numBooks",10));
doc.add(new StoredField("numBooks", 10));

有关更多信息,请参阅。

那么为什么要分别调用IntPoint和StoredField,我们只是将编写的代码量增加了一倍?因为API规定了这一点?如果它困扰你,写一个方便的方法。