【问题标题】:Lucene .Net- What is a good method for creating index that is more complicated that key/value?Lucene .Net-创建比键/值更复杂的索引的好方法是什么?
【发布时间】:2011-07-27 19:44:08
【问题描述】:

我正在启动一个项目,我们正在尝试使用 Lucene .Net 索引 XML 文档的内容。在我发现的小文档中,索引似乎只能由具有单个字符串值的文件组成。我试图索引的数据比简单的键值对稍微复杂一些。

这是一个我想从中生成索引的 xml 文档示例:

    <descriptor>
  <asset guid="2AA7C8F9-2CB1-4A81-9421-C09F1D85939E" generated-date="2011-07-30" generated-by="hw/AutoMfg" generated-with="PMS">

    <!-- information about where the asset can be used -->
    <target>
      <localization>en-us</localization>
      <localization>es-us</localization>
      <environment>desktop</environment>
      <environment>mobile</environment>
    </target>

    <!-- all contents of an asset must have the same version -->
    <version-information>
      <version-number source="content">9.1.123.4</version-number>
      <version-number source="manufacturing">9.1.123.4</version-number>
      <release-label>9.1</release-label>
    </version-information>

    <!-- catalog information about the primary role of the asset -->
    <role>
      <namespace>parent.type.family.some.thing</namespace>
      <mime-type>text/html</mime-type>
      <hwid>abc1234</hwid>
    </role>

  </asset>
</descriptor>

所以我可以看到创建以“描述符”的子元素命名的字段,但是其中的子节点呢?如何索引这些数据?我应该创建一个分隔字符串来表示每个字段的值吗?

例如 field: "Target" Value:"localization: en-us;es-us environment: desktop;mobile | ...

我是否需要像上面的示例一样将数据展平以对其进行索引?

谢谢!

【问题讨论】:

    标签: c# lucene full-text-search lucene.net


    【解决方案1】:

    提供具体建议有点棘手——其中大部分都围绕着您要检索的内容和方式,而不是数据的形状。无论如何,我会从 Simone Chiaretta 在 lucene.net 上的优秀小系列开始(12345)。一个很有帮助的概念是,您可以为给定文档多次索引同一个字段,因此您可能会做出类似的事情:

    Target-Localization:en-us
    Target-Localization:es-us
    Target-Environment:desktop
    Target-Environment:mobile
    

    Lucene 基本上是扁平的,但能够以新颖有趣的方式保持深度,同时保持扁平。

    【讨论】:

      【解决方案2】:

      看看Digester + Lucene。 Digester 的.NET 端口是NDigester

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-07-26
        • 2014-12-18
        • 2021-08-18
        • 1970-01-01
        • 2017-03-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多