Hi, Firstly, I have already tried the request body enclosed in [...] without success. Turns out it was not the only issue. The path was not right for the atomic updates:
On the v2 API: localhost:8983/v2/c/testnode/update/json/commands?commit=true Succeeds localhost:8983/v2/c/testnode/update/json?commit=true Fails localhost:8983/v2/c/testnode/update?commit=true Fails On the old API: localhost:8983/solr/testnode/update/json?commit=true Succeeds localhost:8983/solr/testnode/update/json/docs?commit=true Fails Some insight about what caused my confusion: In the ( https://lucene.apache.org/solr/guide/7_3/updating-parts-of-documents.html#example-updating-part-of-a-document ) page of the Solr Guide, it is not emphasized that for an atomic JSON update to work you must use the command endpoint. Furthermore the example JSONs in that paragraph do not have the actual commands like add/delete/commit level as they are shown in a previous page. ( https://lucene.apache.org/solr/guide/7_3/uploading-data-with-index-handlers.html#sending-json-update-commands ) Either boldly stating that the atomic updates are commands or showing complete JSON requests as examples would have been much clearer. It is also surprising to me that the command endpoint accepts the "list of documents" format where the guide does not mention that. (at the second link provided) Thank you for pointing me in the right direction! Nandor On Tue, May 22, 2018 at 8:14 AM, Yasufumi Mizoguchi <yasufumi0...@gmail.com> wrote: > Hi, > > At least, it is better to enclose your json body with '[ ]', I think. > > Following is the result I tried using curl. > > $ curl -XPOST "localhost:8983/solr/test_core/update/json?commit=true" > --data-binary '{"id":"test1","title":{"set":"Solr Rocks"}}' > { > "responseHeader":{ > "status":400, > "QTime":18}, > "error":{ > "metadata":[ > "error-class","org.apache.solr.common.SolrException", > "root-error-class","org.apache.solr.common.SolrException"], > "msg":"Unknown command 'id' at [5]", > "code":400}} > $ curl -XPOST "localhost:8983/solr/test_core/update/json?commit=true" > --data-binary '[{"id":"test1","title":{"set":"Solr Rocks"}}]' > { > "responseHeader":{ > "status":0, > "QTime":250}} > > Thanks, > Yasufumi > > > 2018年5月22日(火) 1:26 Nándor Mátravölgyi <nandor.ma...@gmail.com>: > > > Hi, > > > > I'm trying to build a simple document search core with SolrCloud. I've > run > > into an issue when trying to partially update doucments. (aka atomic > > updates) It appears to be a bug, because the semantically same request > > succeeds in XML format, while it fails as JSON. > > > > The body of the XML request: > > <add><doc><field name="id">test1</field><field name="title" > > update="set">Solr Rocks</field></doc></add> > > > > The body of the JSON request: > > {"id":"test1","title":{"set":"Solr Rocks"}} > > > > I'm using the requests library in Python3 to send the update request. > > Sending the XML request with the following code works as expected: > > r = requests.post(' > > http://localhost:8983/v2/c/testnode/update/xml?commit=true', > > headers={'Content-type': 'application/xml'}, data=xml) > > > > Sending the JSON request with the following codes return with a > > SolrException: > > r = requests.post(' > > http://localhost:8983/v2/c/testnode/update/json?commit=true', > > headers={'Content-type': 'application/json'}, data=json) > > r = requests.post(' > > http://localhost:8983/solr/testnode/update/json/docs?commit=true', > > headers={'Content-type': 'application/json'}, data=json) > > > > Using the same lines of code to send a JSON request that is not an atomic > > update works as expected. Such JSON request body is like: > > {"id":"test1","title":"Solr Rocks"} > > > > The error message in the response is: ERROR: [doc=test1] unknown field > > 'title.set' > > Here is the log of the exception: https://pastebin.com/raw/VJe5hR25 > > > > Depending on which API I send the request to, the logs are identical > except > > on line 27 and 28: > > This is with v2: > > at > > > > org.apache.solr.handler.UpdateRequestHandlerApi$1. > call(UpdateRequestHandlerApi.java:48) > > at org.apache.solr.api.V2HttpCall.execute(V2HttpCall.java:325) > > and this is with the other: > > at org.apache.solr.core.SolrCore.execute(SolrCore.java:2503) > > at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:711) > > > > I'm using Solr 7.3.1 and I believe I do everything according to the > > documentation. ( > > > > https://lucene.apache.org/solr/guide/7_3/updating-parts- > of-documents.html#atomic-updates > > ) > > The solrconfig.xml and managed-schema files are fairly simple, they have > > code snippets from the examples mostly: https://pastebin.com/199JJkp0 > > https://pastebin.com/Dp1YK46k > > > > This could be a bug, or I can't fathom what I'm missing. Can anyone help > me > > out? > > Thanks, > > Nandor > > >