Passing JSON query in GWT

I'm trying to run the below query from a Java RESTful client -

http://localhost:9200/catalog/drawings/_search? -d '{"query":{"bool":{"must":{"term":{"hashCode":1049279250}}}},"sort":[{"dateLastEdited":{"order":"desc","missing":"_last"}},{"dateCreated":{"order":"desc","missing":"_last"}}]}'

This runs perfectly when entered in a browser but through the RESTful client the error below is thrown.
java.lang.IllegalStateException: Illegal character """ at position 6 is not allowed as a start of a name in a path template " -d '{"query":{...
at org.glassfish.jersey.client.JerseyWebTarget.getUri(
at org.glassfish.jersey.client.JerseyWebTarget.request(
at org.glassfish.jersey.client.JerseyWebTarget.request(

What's possibly wrong here?

Your help will be greatly appreciated.

Not related to elasticsearch here.

May be encode your text? Or use " instead of ".

Better to ask support in the REST client project you are using though.

Thank you for trying to help me. Changing " to " doesn't solve the problem. But I bet the problem is in the way the URL is constructed for Jersey. I'm still searching for the right forum to ask this question. No single forum seems to be the best to post this question.

I continued fiddling with the URL then found this format works http://localhost:nnnn//drawings/_search?xyz:1049279250

That's good but not sure how I can construct a complex query like that. Still seems to be a lot to learn.

I also tried enhancing the query by adding sort orders. This URL worked but not sure how Elasticsearch handles the query construct: http://localhost:nnnn/index/drawings/_search?pretty& visitorHashCode:1049279250& sort:dateLastEdited& order:desc& missing:_last& dateCreated:order:desc& missing:_last
The above query works but I'm not sure how Elasticsearch handles the sort construct.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.