【问题标题】:Error on updating solr index with JSON: Unexpected OBJECT_START使用 JSON 更新 solr 索引时出错:意外的 OBJECT_START
【发布时间】:2015-02-26 10:59:55
【问题描述】:

使用默认 UpdateRequestHandler 发布到 solr 4.10 时,我收到以下错误:

org.apache.solr.common.SolrException; org.apache.solr.common.SolrException: Error parsing JSON field value. Unexpected OBJECT_START

例如,我正在发送以下 json:

[
  {
    "add": {
      "doc": {
        "key": "ph2gi6i8",
        "p_profit_tf": "22.248070175438603",
        "p_discount_tf": "18.771929824561404",
        "p_designer_s": "POP CANDY"
      },
      "overwrite": true
    }
  }
]

这是基于此处 solr 文档中的示例架构:https://wiki.apache.org/solr/UpdateJSON

在 schema.xml 中配置的唯一必填字段是关键字段

【问题讨论】:

    标签: json solr solr4


    【解决方案1】:

    你不能在数组中传递它,而是通过换行符分隔的对象:

      {
        "add": {
          "doc": {
            "key": "ph2gi6i8",
            "p_profit_tf": "22.248070175438603",
            "p_discount_tf": "18.771929824561404",
            "p_designer_s": "POP CANDY"
          },
          "overwrite": true
        }
      }
      {
        "add": {
          "doc": {
            "key": "ph2gi6i8",
            "p_profit_tf": "22.248070175438603",
            "p_discount_tf": "18.771929824561404",
            "p_designer_s": "POP CANDY"
          },
          "overwrite": true
        }
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-25
      • 1970-01-01
      • 1970-01-01
      • 2011-07-16
      • 2020-05-07
      相关资源
      最近更新 更多