Thank you.
The json file I was sending contained the following (which I have tried on a single line and also on a single line without spaces)
`
{
“add-field”:{
“name”:“recordNumber”,
“type”:“string”,
“indexed”:true,
“stored”:true,
“docValues”:true,
“omitNorms”:true,
“omitTermFreqAndPositions”:true,
“sortMissingLast”:true,
“multiValued”:false
},
“add-field”:{
“name”:“characterization”,
“type”:“text_general”,
“indexed”:true,
“stored”:true,
“omitNorms”:true,
“omitTermFreqAndPositions”:true,
“sortMissingLast”:true,
“multiValued”:false
},
“add-field”:{
“name”:“primaryname”,
“type”:“text_general”,
“indexed”:true,
“stored”:true,
“omitNorms”:true,
“omitTermFreqAndPositions”:true,
“sortMissingLast”:true,
“multiValued”:false
},
“add-field”:{
“name”:“originator”,
“type”:“text_general”,
“indexed”:true,
“stored”:true,
“omitNorms”:true,
“omitTermFreqAndPositions”:true,
“sortMissingLast”:true,
“multiValued”:false
},
“add-field”:{
“name”:“createdOn”,
“type”:“tdate”,
“indexed”:true,
“stored”:true,
“docValues”:true,
“omitNorms”:true,
“omitTermFreqAndPositions”:true,
“multiValued”:false
},
“add-field”:{
“name”:“report”,
“type”:“text_en_splitting”,
“indexed”:true,
“stored”:true,
“omitNorms”:false,
“omitTermFreqAndPositions”:false,
“multiValued”:false
}
}
`
This is the error I was getting
`
ok: [malpdwfftsla001 → localhost] => {“changed”: false, “content”: “{\n "responseHeader":{\n "status":0,\n "QTime":0},\n "errors":[{"errorMessages":"Error parsing schema operations :The JSON must be an Object of the form {\"command\": {…},…"}]}\n”, “content_length”: “185”, “content_type”: “text/plain;charset=utf-8”, “redirected”: false, “status”: 200}
`
I guess it would have been helpful if I had used wireshark or similar to capture what URI was actually POSTing, didn’t think to do that at the time.
I tried both with and without the leading space when fetching the json at various points.
`
- name: fetch schema json
set_fact:
schema: " {{ lookup(‘file’, ‘schema.json’)}}"
`
I tried using vars_files to load the contents but because there are multiple “add-field” keys, I only got the last defined “add-field” command. I played with converting to a list of objects and using with_items on the uri action (below) but still got the above error for each iteration of the list.
`
- name: add the schema
uri:
url: “http://{{ solr_node }}:8983/solr/evaluation/schema”
method: POST
body: “{{ item }}”
body_format: json
return_content: yes
with_items:
schema
delegate_to: localhost
`
For now I have abandoned modifying solr via the rest api and am pushing the schema files I want to use out directly from ansible.