【问题标题】:Projection of Collections in lucene query in hibernate search休眠搜索中 lucene 查询中集合的投影
【发布时间】:2014-02-26 21:32:49
【问题描述】:

我正在尝试使用 @IndexEmbedded 注释进行索引。当我使用 Luke 进行检查时,结果是正确的。(我正在获取 List 的所有元素)。

但是当我尝试在 Lucene Query 的投影中使用这个列表时,我得到了 null。

我在某处读到 “投影不适用于通过 @IndexedEmbedded 索引的集合或地图”

有没有其他方法可以投影这个列表。

  @Indexed
public class Item {

   ...

  @IndexedEmbedded
  private List<Keyword> keywords;

   ...
}

@Indexed
public class Keyword {

   ...

  @Field
  private String value;

   ...
}

【问题讨论】:

    标签: java lucene indexing hibernate-search


    【解决方案1】:

    正确,根据文档:

    you can only project simple properties of the indexed entity or its embedded associations. This means you cannot project a whole embedded entity.
    
    projection does not work on collections or maps which are indexed via @IndexedEmbedded
    

    可以尝试通过对文档中实际关键字的顺序和内容进行编码来为关键字实现自定义双向字段桥。不知道这是否是个好主意。

    【讨论】:

    • 好的,我同意你说的。但是我刚刚发现,在投影时,如果我将 FullText.DOCUMENT 指定为参数,它会从 lucene 索引返回文档行。我可以使用这个文档来组合对象吗?会不会影响性能?
    • 当然,您可以获取整个 Lucene 文档并从那里获取
    • 好的,感谢您的反馈。
    猜你喜欢
    • 2012-11-26
    • 2015-02-01
    • 2021-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多