【问题标题】:How to index an array of hashes with Solr如何使用 Solr 索引散列数组
【发布时间】:2016-02-16 21:54:03
【问题描述】:

我需要索引具有以下数据结构的专利目录:

  "cpc": [
    {
      "class": "61",
      "section": "A",
      "sequence": "1",
      "subclass": "K",
      "subgroup": "06",
      "main-group": "45",
      "classification-value": "I"
    },
    {
      "class": "61",
      "section": "A",
      "sequence": "2",
      "subclass": "K",
      "subgroup": "506",
      "main-group": "31",
      "classification-value": "I"
    }
]

我想知道这里的正确方法是什么。我也许可以使用 cpc.class 并将其与 multiValued="true" 结合使用。

我想查找与某个 CPC 代码匹配的文档。 CPC 代码可以是部分的。现在我的解决方案是简单地使用 multiValued=true 的嵌套引用。有更好的方法吗?

<field name="cpc.class"                 type="int"    indexed="true" stored="true" multiValued="true" />
<field name="cpc.section"               type="string" indexed="true" stored="true" multiValued="true" />
<field name="cpc.sequence"              type="int"    indexed="true" stored="true" multiValued="true" />
<field name="cpc.subclass"              type="string" indexed="true" stored="true" multiValued="true" />
<field name="cpc.subgroup"              type="int"    indexed="true" stored="true" multiValued="true" />
<field name="cpc.main-group"            type="int"    indexed="true" stored="true" multiValued="true" />
<field name="cpc.classification-value"  type="string" indexed="true" stored="true" multiValued="true" />

这个实现的问题是它返回的文档实际上与搜索条件不匹配。示例:

"cpc.section:A",
"cpc.class:61",
"cpc.subclass:Q",
"cpc.main-group:8"

我得到的文件没有这种组合。我认为当前的方式实现了搜索,以便每个字段都是一个列表,并返回任何组合的匹配值。我需要缩小范围,以便只返回正确的组合。

【问题讨论】:

  • 你想找到什么?围绕发现而不是围绕原始数据结构构建 Solr 索引。
  • CPC 是分层代码,不是吗?如果您为专利索引建模,请考虑hierarchical facets
  • 我想搜索文档,以便只有在一个哈希中存在搜索词时才返回结果。 multiValued 方式产生的结果实际上与搜索条件不匹配。在问题中查看更多更新。
  • 您使用的是 Solr 还是 Lucene?哪个版本?如果是 Solr,您如何访问它:SolrJ、Solr.NET、...?

标签: json indexing solr


【解决方案1】:

使用 Solr 对其进行索引的最佳方法是将嵌套数据结构 (cpcs) 拆分为平面文档,并在其中包含专利 ID。这样就可以搜索到部分 cpcs 的任意组合。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-31
    • 1970-01-01
    • 2018-01-02
    • 1970-01-01
    • 2018-08-29
    • 2014-10-22
    • 2014-04-25
    相关资源
    最近更新 更多