在 Lucene 6 中,LongField 和 IntField 已重命名为 LegacyLongField 和 LegacyIntField,已弃用 JavaDoc建议改用 LongPoint 和 IntPoint 类。
但是,似乎不可能建立这些 XPoint 字段的术语词汇表(=枚举所有不同的值)。 Lucene mailing list entry证实了
PointFields are different than conventional inverted fields, so they also don't show up in fields(). You cannot get a term dictionary from them.
作为第三种选择,可以添加 NumericDocValuesField 类的字段,据我所知,它也没有提供构建术语词汇表的方法。
鉴于构建术语词汇表的要求,在 Lucene 6 中是否有一种未弃用的索引数字字段的方法?
最佳答案
在我的例子中,我只是将字段复制一次作为 LongPoint,一次作为存储的非索引字段,这两个字段具有相同的名称。
我的情况大致是
doc.add(new NumericDocValuesField("ts", timestamp.toEpochMilli()));
doc.add(new LongPoint("ts", timestamp.toEpochMilli()));
doc.add(new StoredField("ts", timestamp.toEpochMilli()));
虽然有点难看,但是可以把它想象成给存储的字段加一个索引。 这些字段类型可以互不干扰地使用相同的名称。
用于基于文档年龄的评分的 DocValues 和用于范围查询的 LongPoint。
关于java - Lucene 6 - 使用术语词汇表存储数字字段的推荐方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42482451/