【问题标题】:Using Lucene to query related document fields使用Lucene查询相关文档字段
【发布时间】:2015-08-30 21:29:12
【问题描述】:

假设我有通过 DirectedBy 和 Starring 边缘连接到 Person 顶点的 Movie 顶点。

考虑这个按预期工作的 OrientDB 查询:

select *, out("DirectedBy").Name, out("Starring").Name from Movie where out("DirectedBy") CONTAINS (Name = 'John Ford')

这将正确返回由名为“John Ford”的 Persons 导演的所有电影。但是,我想使用 Lucene 全文搜索来执行查询以提供更多的灵活性。

我认为我的索引设置正确,因为直接在 Persons 表上的查询成功会产生结果:

select * from name lucene 'John Ford'

但是,在我的 Movie 顶点查询中尝试使用 Lucene 运算符不会产生任何结果:

select *, out("DirectedBy").Name, out("Starring").Name from Movie where out("DirectedBy") CONTAINS (Name LUCENE 'John Ford')

我做错了吗?还是我在尝试做一些不可能的事情?

【问题讨论】:

    标签: lucene relationship graph-theory orientdb vertices


    【解决方案1】:

    为了使用 LUCENE,你应该用它来执行 SELECT,而不是在 contains 中。试试这个应该超级快的:

    select *, out("DirectedBy").Name, out("Starring").Name
    from (
      select expand( in("DirectedBy") ) from person where Name lucene 'John Ford'
    )
    

    内部 SELECT 使用 LUCENE 查找“John Ford”,然后通过 in("DirectedBy") 跨越连接的电影。我使用了expand(),因为您需要该结果用于显示所需信息的外部 SELECT。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多