1

We are trying to perform this curl command:

curl -X POST -H "Content-type:application/json" -u "USERNAME":"PASSWORD" "https://gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/CLUSTER_ID/solr/COLLECTION_NAME/schema/analysis/synonyms/english" --data-binary "["ARS","Argentinian Peso"]"

The result:

{
"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)\n\tat org.noggit.JSONParser.nextEvent(JSONParser.java:983)\n\tat org.noggit.ObjectBuilder.getArray(ObjectBuilder.java:149)\n\tat org.noggit.ObjectBuilder.getVal(ObjectBuilder.java:59)\n\tat org.noggit.ObjectBuilder.getVal(ObjectBuilder.java:37)\n\tat org.noggit.ObjectBuilder.fromJSON(ObjectBuilder.java:33)\n\tat org.apache.solr.rest.RestManager$ManagedEndpoint.parseJsonFromRequestBody(RestManager.java:425)\n\tat org.apache.solr.rest.RestManager$ManagedEndpoint.post(RestManager.java:351)\n\tat org.restlet.resource.ServerResource.doHandle(ServerResource.java:454)\n\tat org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:359)\n\tat org.restlet.resource.ServerResource.handle(ServerResource.java:1044)\n\tat org.restlet.resource.Finder.handle(Finder.java:236)\n\tat org.restlet.routing.Filter.doHandle(Filter.java:150)\n\tat org.restlet.routing.Filter.handle(Filter.java:197)\n\tat org.restlet.routing.Router.doHandle(Router.java:422)\n\tat org.restlet.routing.Router.handle(Router.java:639)\n\tat org.restlet.routing.Filter.doHandle(Filter.java:150)\n\tat org.restlet.routing.Filter.handle(Filter.java:197)\n\tat org.restlet.routing.Filter.doHandle(Filter.java:150)\n\tat org.restlet.routing.Filter.handle(Filter.java:197)\n\tat org.restlet.routing.Filter.doHandle(Filter.java:150)\n\tat org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:140)\n\tat org.restlet.routing.Filter.handle(Filter.java:197)\n\tat org.restlet.routing.Filter.doHandle(Filter.java:150)\n\tat org.restlet.routing.Filter.handle(Filter.java:197)\n\tat org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202)\n\tat org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:75)\n\tat org.restlet.Application.handle(Application.java:385)\n\tat org.restlet.routing.Filter.doHandle(Filter.java:150)\n\tat org.restlet.routing.Filter.handle(Filter.java:197)\n\tat org.restlet.routing.Router.doHandle(Router.java:422)\n\tat org.restlet.routing.Router.handle(Router.java:639)\n\tat org.restlet.routing.Filter.doHandle(Filter.java:150)\n\tat org.restlet.routing.Filter.handle(Filter.java:197)\n\tat org.restlet.routing.Router.doHandle(Router.java:422)\n\tat org.restlet.routing.Router.handle(Router.java:639)\n\tat org.restlet.routing.Filter.doHandle(Filter.java:150)\n\tat org.restlet.routing.Filter.handle(Filter.java:197)\n\tat org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202)\n\tat org.restlet.Component.handle(Component.java:408)\n\tat org.restlet.Server.handle(Server.java:507)\n\tat org.restlet.engine.connector.ServerHelper.handle(ServerHelper.java:63)\n\tat org.restlet.engine.adapter.HttpServerHelper.handle(HttpServerHelper.java:143)\n\tat org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1117)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\n\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:595)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:191)\n\tat org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:72)\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:266)\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:208)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)\n\tat org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:499)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)\n\tat org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)\n\tat java.lang.Thread.run(Thread.java:745)\n",
"code": 500
}
}
curl: (3) [globbing] unmatched close brace/bracket in column 5

Do you have any idea why? The API doesn't support "multi-term" synonyms?

Thank you for your help.

2 Answers2

1

Replace your outer double quotes with single ones

curl -X POST ... --data-binary '["ARS","Argentinian Peso"]'

Before that you have the following strings quoted "[", ",", "]", the space after "Argentinian" was not quoted and everything after that was not considered as part of --data-binary arguments.

EricLavault
  • 12,130
  • 3
  • 23
  • 45
Ivan
  • 3,781
  • 16
  • 20
  • "["funny","jocular","whimiscal"]" – Daniel Moura Oct 24 '16 at 16:28
  • Like this "["funny","jocular","whimiscal"]" is working really well. This is Windows parser. Any idea? – Daniel Moura Oct 24 '16 at 16:30
  • 1
    @DanielMoura I edited this post (pending), there is a typo (missing "[") try with `'["ARS","Argentinian Peso"]'`. There is no issue with `"["funny","jocular","whimiscal"]"` because there is no space in the arguments. You should enclose "double-quoted" arguments with a single quote, and escape single quotes within each arguments. – EricLavault Oct 24 '16 at 16:32
  • Something like this? curl ... --data-binary '"["ARS","Argentinian Peso"]"' It's not working... :( – Daniel Moura Oct 24 '16 at 16:37
  • Like this: curl ... --data-binary '["ARS","Argentinian Peso"]' Doesn't work too. :( – Daniel Moura Oct 24 '16 at 16:38
  • @DanielMoura same error? please share the full curl (three dots should not be copied, I've just used them to shorten the command) – Ivan Oct 24 '16 at 17:00
  • Hi @Ivan! Thanks for your help. Please check here: https://www.wetransfer.com/downloads/8a0b64484254e8ed28c010add5df239e20161025082516/e1c6fbbdff11dc5fab56c45bf81e33c820161025082516/a1486b – Daniel Moura Oct 25 '16 at 08:26
  • @DanielMoura your #2 option is the most correct. It submits valid json. Unfortunately it is not of the format expected by Solr. – Ivan Oct 25 '16 at 08:51
  • @DanielMoura could you please check your solr log for something like `Processing update to ` and see what does it receive. If necessary enable logging for [org.apache.solr.rest.ManagedResource](https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/rest/ManagedResource.java#L364). Also please change your authorization as the file you've shared allows anyone on the internet to post to your solr which I guess is undesired. – Ivan Oct 25 '16 at 09:01
  • @Ivan, I can't access to Solr log, I'm running Watson Retrieve and Rank service... any idea how can I mitigate this situation? – Daniel Moura Oct 25 '16 at 10:17
  • @DanielMoura as for the authorization - first thing is delete your comment with logs attached as it had the credentials. For credential change you can ask your support but the easiest way would be to recreate your cluster if you haven't loaded much data into it – Ivan Oct 25 '16 at 10:48
  • @DanielMoura as for the upload, try putting your json `["ARS","Argentinian Peso"]` into a file (e.g. `example.json` and pass that file name as a parameter `--data-binary @example.json`). By using your command #2 on Mac I was able to get success response so you're close – Ivan Oct 25 '16 at 10:50
  • @Ivan how can I delete a comment?! ): – Daniel Moura Oct 25 '16 at 13:06
  • @Ivan, It works with the parameter `--data-binary @example.json`. Thank you! But now I run with `["W1","W 1"],["w2","w 2"]` for multi entries without succes. – Daniel Moura Oct 25 '16 at 13:20
  • @DanielMoura 1) try `[["W1","W 1"],["w2","w 2"]]`. Input should be either valid json object or json array. Trying something like http://jsoneditoronline.org to validate your json is correct 2) generally on stackoverflow asking additional questions is against the rules. Welcome to the family :) One posting is one question. 3) as per [What should I do when someone answers my question?](http://stackoverflow.com/help/someone-answers) please consider marking the answer as accepted so this question won't be attracting more people. If you'll be having more questions - please create a new posting – Ivan Oct 25 '16 at 13:33
  • Thanks @Ivan, 1) I just tried and doesn't work. I have thousands of entries to upload and I don't know what/how can do. With simple json files is not possible. 2) and 3) I created new cluster credentials. I uploaded the wrong files (shit happens). Thanks for the advise. 3) – Daniel Moura Oct 25 '16 at 14:19
  • Re: 1 plase open a new question, don't forget to share the stacktrace there and mention the data you're trying to submit. I'm not a solr expert but we have a lot of knowledgeable people here – Ivan Oct 25 '16 at 14:25
0

Don't forget to leverage the Solr Admin UI. If you can create the query on the UI, once you press the submit button, you get a URL at the top of the results. I've used this several times to help me with the "fiddly bits" of the syntax.

jb62
  • 2,224
  • 2
  • 14
  • 23
  • Hmmm.... Should have looked at your example more closely - not sure my advice pertains. – jb62 Oct 24 '16 at 17:05