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

我想索引&在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子文档和块连接.

翻译自:https://stackoverflow.com/questions/26386280/how-to-index-search-nested-json-in-solr-4-9-0

转载注明原文:如何索引和搜索Solr 4.9.0中的嵌套Json