We are trying to create/upload new synonyms to Solr as managed resources. We are facing some problems when we create multi-term synonyms like, for example, "United States of America" or "Spider Man". The Solr Documentation provides a curl command example for single-term synonyms but doesn't have a curl command example for multi-term.
We tried the following command and some variants:
1)
`curl -X POST -H "Content-type:application/json" ... --data-binary "["ARS","Argentinian Peso"]"`
2)
curl -X POST -H "Content-type:application/json" ... --data-binary '["ARS","Argentinian Peso"]'
3)
curl -X POST -H "Content-type:application/json" ... --data-binary [["ARS","Argentinian Peso"]]
For the three we got the following errors:
1)
{
"responseHeader":{
"status":500,
"QTime":2},
"error":{
"msg":"Expected ',' or ']': char=(EOF),position=16 BEFORE='[ARS,Argentinian'",
"trace":"org.noggit.JSONParser$ParseException: Expected ',' or ']': char=(EOF),position=16 BEFORE='[ARS,Argentinian'\n\tat org.noggit.JSONParser.err(JSONParser.java:356)...",
"code":500}}
curl: (3) [globbing] unmatched close brace/bracket in column 5
2)
{
"responseHeader": {
"status": 500,
"QTime": 2
},
"error": {
"msg": "Bad Request",
"trace": "Bad Request (400) - Unsupported update format java.lang.String\n\tat org.apache.solr.rest.ManagedResource.doPut(ManagedResource.java:410)...",
"code": 500
}
}
3)
{
"responseHeader": {
"status": 500,
"QTime": 2
},
"error": {
"msg": "Expected ',' or ']': char=P,position=18 BEFORE='[[ARS,Argentinian P' AFTER='eso]]'",
"trace": "org.noggit.JSONParser$ParseException: Expected ',' or ']': char=P,position=18 BEFORE='[[ARS,Argentinian P' AFTER='eso]]'\n\tat org.noggit.JSONParser.err(JSONParser.java:356)...",
"code": 500
}
}
After we tried to create them from json file with success; we used the following curl command:
4)
curl -X POST -H "Content-type:application/json" ... --data-binary @synonyms_test.json
The synonyms_test.json has:
["USA","United States of America"]
After we tried to extend this 'workaround' because we need to create/upload thousands of synonyms to an existing collection. Then we decide to fill the json file with array of arrays (a valid json content):
[["aaa", "aaa1"],["bbb", "bbb1"]]
And the result was:
4)
{
"responseHeader": {
"status": 500,
"QTime": 2
},
"error": {
"msg": "java.util.ArrayList cannot be cast to java.lang.String",
"trace": "java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String ...",
"code": 500
}
}
Do you have any idea how to solve this?
Regards, DM