对于我正在处理的问题,我有大部分父/子文档解决方案,但我遇到了一个障碍:从迭代子文档的方面内部,我需要访问父文档字段的值。我有(或者我可以得到)父文档 ID(来自子文档的 _parent 字段,或者最坏的情况是通过再次将其索引为普通字段)但这是一个“外部”ID,而不是我的节点内部 ID需要从字段缓存中加载字段值。(我使用的是默认路由,因此父文档肯定与子文档在同一个分片中。)
更具体地说,这是我目前在 FacetCollector 中的内容(ES 0.20.6):
protected void doSetNextReader(IndexReader reader, int docBase) throws IOException {
/* not sure this will work, otherwise I can index the field seperately */
parentFieldData = (LongFieldData) fieldDataCache.cache(FieldDataType.DefaultTypes.LONG, reader, "_parent");
parentSpringinessFieldData = (FloatFieldData) fieldDataCache.cache(FieldDataType.DefaultTypes.FLOAT, "springiness");
/* ... */
protected void doCollect(int doc) throws IOException {
long parentID = parentFieldData.value(doc); // or whatever the correct equivalent here is
// here's the problem:
parentSpringiness = parentSpringinessFieldData.value(parentID)
// type error: expected int (node-internal ID), got long (external ID)
有什么建议么?(我还不能升级到 0.90,但很想知道这是否有帮助。)