Tom Fowler
Tom Fowler

Reputation: 134

Error on updating solr index with JSON: Unexpected OBJECT_START

When posting to solr 4.10 using the default UpdateRequestHandler, I receive the following error:

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

I am sending in, as an example, the following json:

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

This was based on the example schema from the solr docs here: https://wiki.apache.org/solr/UpdateJSON

The only required fields configured in the schema.xml is the key field

Upvotes: 1

Views: 1391

Answers (1)

Tjorriemorrie
Tjorriemorrie

Reputation: 17282

You must not pass it through in an array, but pass through newline delimited objects:

  {
    "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
    }
  }

Upvotes: 3

Related Questions