Searching with uri request

This will seem like a silly question, but I don't have much experience with
http requests/responses.
I am trying to run a query against elastic search using the Java
URLConnection API:

The following gives me all documents:
URL es = new URL("http://localhostb:9200/messages/chat/_search);
URLConnection yc = es.openConnection();

but this returns an error
URL es = new URL("http://localhostb:9200/messages/chat/_search -d
'{"query":{"term":{"from_jid":"from0"}}}'");
URLConnection yc = es.openConnection();

Can someone tell me what's wrong with this request?

Thanks.

--

The last code is not a valid URL but looks like a curl request.
You can not do that that way.

If you want to reinvent the wheel (i mean using Java URL API), you will have to manage the payload send process.

Why not using ES or REST Java client?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 7 janv. 2013 à 21:50, emj11 jagdhar@gmail.com a écrit :

This will seem like a silly question, but I don't have much experience with http requests/responses.
I am trying to run a query against elastic search using the Java URLConnection API:

The following gives me all documents:
URL es = new URL("http://localhostb:9200/messages/chat/_search);
URLConnection yc = es.openConnection();

but this returns an error
URL es = new URL("http://localhostb:9200/messages/chat/_search -d '{"query":{"term":{"from_jid":"from0"}}}'");
URLConnection yc = es.openConnection();

Can someone tell me what's wrong with this request?

Thanks.

--

--

Hi David, thanks for your response. Not a fan of reinventing the wheel.
I would like to make these searches over http rather than tcp. If I use ES
than it will be over tcp.

Sounds like I should use REST. But how do I use REST within Java to talk
to the ES Server?

Thanks.

--

Have a look at https://github.com/searchbox-io/Jest
I'm also working on a SPORE specification for ES but it's not ready yet: https://github.com/dadoonet/spore-elasticsearch

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 7 janv. 2013 à 22:52, emj11 jagdhar@gmail.com a écrit :

Hi David, thanks for your response. Not a fan of reinventing the wheel.
I would like to make these searches over http rather than tcp. If I use ES than it will be over tcp.

Sounds like I should use REST. But how do I use REST within Java to talk to the ES Server?

Thanks.

--

Ok. Thanks David.

--