json - 如何使用 Solr 索引哈希数组

标签 json indexing solr

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

  "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 代码可以是部分的。现在我的解决方案只是使用 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 对此进行索引的最佳方法是将嵌套数据结构 (cpcs) 拆分为平面文档,并将 Patent_id 包含在其中。这样就可以搜索部分 cpc 的任意组合。

关于json - 如何使用 Solr 索引哈希数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33724556/

相关文章:

mysql - Magento CE 2.2 巨大的目录索引问题

linux - 来自私有(private)网络的 Solr 连接

java - 如何在 Solr 索引中创建嵌套文档?

jQuery - 查找 json 中的某些属性

当 html 在 JSON 数据包中传递时,Javascript 错误

oracle 日期时间字段索引

python - 如何拆分一个元素并用python替换列表中的两个部分

hadoop - Hue 无法访问 CDH 中的 Solr 集合

javascript - 如何从存储在 localstorage 中的 json 字符串在 HTML 页面中显示 json 数据

json - 在执行json解码后,输出为空,但未发生解析错误