json - 如何在 Solr 4.9.0 中索引和搜索嵌套的 Json

标签 json solr

我想在 solr 中索引和搜索嵌套的 json。这是我的 json 代码

{
        "id": "44444",
        "headline": "testing US",
        "generaltags": [
            {
                "type": "person",
                "name": "Jayalalitha",
                "relevance": "0.334",
                "count": 1
            },
            {
                "type": "person",
                "name": "Kumar",
                "relevance": "0.234",
                "count": 1
            }
        ],
        "socialtags": {
            "type": "SocialTag",
            "name": "US",
            "importance": 2
        },
        "topic": {
            "type": "Topic",
            "name": "US",
            "score": "0.936"
        }
    }


当我尝试索引时,我收到错误“解析 JSON 字段值时出错。意外的 OBJECT_START”

当我们尝试使用多值字段和索引时,我们无法使用多值字段进行搜索?它返回的“未定义字段”

如果我需要对 schema.xml 文件进行任何更改,请提供建议?

最佳答案

您正在文档中嵌套子文档。您需要对 JSON 中的嵌套子文档使用正确的语法:

[
  {
    "id": "1",
    "title": "Solr adds block join support",
    "content_type": "parentDocument",
    "_childDocuments_": [
      {
        "id": "2",
        "comments": "SolrCloud supports it too!"
      }
    ]
  },
  {
    "id": "3",
    "title": "Lucene and Solr 4.5 is out",
    "content_type": "parentDocument",
    "_childDocuments_": [
      {
        "id": "4",
        "comments": "Lots of new features"
      }
    ]
  }
]

看看这个 article它描述了 JSON 子文档和块连接。

关于json - 如何在 Solr 4.9.0 中索引和搜索嵌套的 Json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26386280/

相关文章:

ajax - IE9 JSON 数据到 Iframe : "Do You Want To Open or Save This File?"

java - solr 不能删除任何东西

search - 为什么搜索查询应该(或不应该)只返回文档 ID?

java - Solr 中缺少强制 uniquekey 字段错误

javascript - ajax 发送 POST 两次,从 PHP 接收双重/重复结果

javascript - setInterval启动我的页面在生成30+数据时就卡顿了

javascript - Android 和 JavaScript Parse API 之间不一致

javascript - Rails 5 - 以 json 格式将数据从 Controller 发送到 javascript

solr - 如何对星号进行 urlencode

mysql - SOLR - MYSQL - 查询结果