Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad JSON for array atomic updates #200

Closed
serggl opened this issue Jul 17, 2019 · 0 comments · Fixed by #201
Closed

Bad JSON for array atomic updates #200

serggl opened this issue Jul 17, 2019 · 0 comments · Fixed by #201

Comments

@serggl
Copy link
Contributor

serggl commented Jul 17, 2019

When I try document.add_field(indexed_name, ['value1', 'value2'],{update: :set}) rsolr will build JSON in a wrong manner, so Solr returns Error parsing JSON field value. Unexpected OBJECT_START

Here is a sample JSON, which is being produced for the sample above

{
  "id": "Post 917", 
  "type": ["Post"], 
  "tag_list_sms": [
    {"set": "value 1"}, 
    {"set": "value 2"}
  ]
}

An error will be

     RSolr::Error::Http:
       RSolr::Error::Http - 400 Bad Request
       Error: {"responseHeader":{"status":400,"QTime":3},"error":{"msg":"Error parsing JSON field value. Unexpected OBJECT_START at [77], field=tag_list_sms","code":400}}
     
       URI: http://localhost:8983/solr/default/update?wt=json
       Request Headers: {"Content-Type"=>"application/json"}

I believe a proper format should be:

  "tag_list_sms": {
      "set": ["value 1", "value 2"]
    }
jrochkind added a commit that referenced this issue Dec 15, 2021
[fixes #200] Fix JSON generator for atomic updates of array fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant