Query result with jQuery differs from cURL result

Hi,

I try to send queries I tested successfully with cURL with jQuery to ES,
but the result differs from the result with cURL.

After a Wireshark session I found out, that jQuery sends my query as URL
parameters while cURL send the query as JSON in the body of the request
as application/x-www-form-urlencoded.

Does someone know how to send a query via jQuery properly to ES?

Currently I call ES with jQuery with this statement

$.ajax({
     type:"GET",
     data: getServEventStream,
     dataType:"json",
     url:"http://localhost:9200/billingevents/server/_search",
     success:function (data) {
       // some magic...
     }
 });

Best,

Oliver

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

May be adding processData: false could help?
Or using POST?

I did it like this a long time ago: https://github.com/dadoonet/devoxxfr_demo/blob/gh-pages/index.html#L592

Hope this helps

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

Le 3 août 2013 à 23:14, "Oliver B. Fischer" mailsink@swe-blog.net a écrit :

Hi,

I try to send queries I tested successfully with cURL with jQuery to ES, but the result differs from the result with cURL.

After a Wireshark session I found out, that jQuery sends my query as URL parameters while cURL send the query as JSON in the body of the request as application/x-www-form-urlencoded.

Does someone know how to send a query via jQuery properly to ES?

Currently I call ES with jQuery with this statement

$.ajax({
type:"GET",
data: getServEventStream,
dataType:"json",
url:"http://localhost:9200/billingevents/server/_search",
success:function (data) {
// some magic...
}
});

Best,

Oliver

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

With processData : false and using POST: It works!

Thank you very much!

Best,

Oliver

Am 03.08.13 23:33, schrieb David Pilato:

May be adding processData: false could help?
Or using POST?

I did it like this a long time ago:
JUG Elasticsearch Twitter Demo

Hope this helps

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.