【问题标题】:Search each element in string array for multiple terms using RavenDB and lucene使用 RavenDB 和 lucene 在字符串数组中的每个元素中搜索多个术语
【发布时间】:2014-12-10 15:22:51
【问题描述】:

我的 RavenDB 中有以下对象:

Object1:

{
  "Texts" : [ "one two", "three four" ]
}

Object2:

{
  "Texts" : [ "one three", "two four" ]
}

我想查找Texts 中的字符串包含onetwo 这两个术语的所有对象。

如果我索引该字段

from doc in docs.Objects select new { Texts }

并使用StandardAnalyzer 对其进行分析,当我只想要Object1 时,以下查询将返回Object1Object2

Texts:(one AND two)

我该如何解决这个问题?

【问题讨论】:

    标签: c# lucene ravendb


    【解决方案1】:

    如果你需要它,你可以这样做:

    from doc in docs
    from text in doc.Tests
    select new { Text = text }
    

    请注意,这是一个扇出索引,如果每个文档有很多文本,则需要注意所需的资源。

    【讨论】:

    • 我明白了,然后我会分析Text 字段? (我假设Tests 是一个错字,你的意思是Texts
    【解决方案2】:

    您的要求并不真正兼容。 这份文件呢?

    {
      "Texts" : [ "two one", "three four" ]
    }
    

    你想在搜索one AND two时找到它吗?

    如果不是,只需进行词组搜索,如果是,则不使用扇出就无法真正做你想做的事。

    【讨论】:

    • 是的,我也想找到那个文件。重要的是能够执行搜索。可以调整查询、索引或其他任何需要的内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多