ES GET Query in C#

I'm not sure how to send a GET request with a JSON payload in C#. The
framework will throw an error when I try to get a RequestStream to write to
it.

Can someone explain how I can emulate the CURL GET command (curl -GET
"http://localhost:9200/index/type/_search" -d "{ "query" : .... }") in C#?

I was looking at NEST and it seems like it uses Thrift. Is there a
requirement that in C# I would need to use Thrift instead of an HTTP GET
Request with a payload??

Also, I've heard that GET with a payload is invalid, but read somewhere
that HTTP RFC says that it's ok.

Thanks,
Nick

--

POST should work too.

On Mon, Sep 24, 2012 at 10:37 AM, TheOutlander theoutlander@gmail.com wrote:

I'm not sure how to send a GET request with a JSON payload in C#. The
framework will throw an error when I try to get a RequestStream to write to
it.

Can someone explain how I can emulate the CURL GET command (curl -GET
"http://localhost:9200/index/type/_search" -d "{ "query" : .... }") in C#?

I was looking at NEST and it seems like it uses Thrift. Is there a
requirement that in C# I would need to use Thrift instead of an HTTP GET
Request with a payload??

Also, I've heard that GET with a payload is invalid, but read somewhere
that HTTP RFC says that it's ok.

Thanks,
Nick

--

--

I tried that in curl but I don't get any hits.... I'm not sure if it works.
Have you tried it?

Thanks for the quick response!

On Monday, September 24, 2012 10:45:50 AM UTC-7, Raffaele Sena wrote:

POST should work too.

On Mon, Sep 24, 2012 at 10:37 AM, TheOutlander <theout...@gmail.com<javascript:>>
wrote:

I'm not sure how to send a GET request with a JSON payload in C#. The
framework will throw an error when I try to get a RequestStream to write
to
it.

Can someone explain how I can emulate the CURL GET command (curl -GET
"http://localhost:9200/index/type/_search" -d "{ "query" : .... }") in
C#?

I was looking at NEST and it seems like it uses Thrift. Is there a
requirement that in C# I would need to use Thrift instead of an HTTP GET
Request with a payload??

Also, I've heard that GET with a payload is invalid, but read somewhere
that HTTP RFC says that it's ok.

Thanks,
Nick

--

--

yup! Not sure if the Content-Type matters, since what I am sending is
NOT x-www-form-urlencoded :slight_smile:

sh> curl -v -i http://localhost:9200/_search -XPOST -d
'{"query":{"query_string":{"query":"pdf"}}}'

POST /_search HTTP/1.1
User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Host: localhost:9200
Accept: /
Content-Length: 42
Content-Type: application/x-www-form-urlencoded

{"query":{"query_string":{"query":"pdf"}}}HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Type: application/json; charset=UTF-8
Content-Type: application/json; charset=UTF-8
< Content-Length: 1930
Content-Length: 1930

{"took":11,"timed_out":false,"_shards":{"total":15,"successful":15,"failed":0},"hits":{"total":4317,"max_score":2.3064148,"hits":[{"_index":"names","_type":"document","_id":"-3069932108639787315","_score":2.3064148,
"_source" : {...}}]}

On Mon, Sep 24, 2012 at 11:14 AM, TheOutlander theoutlander@gmail.com wrote:

I tried that in curl but I don't get any hits.... I'm not sure if it works.
Have you tried it?

Thanks for the quick response!

On Monday, September 24, 2012 10:45:50 AM UTC-7, Raffaele Sena wrote:

POST should work too.

On Mon, Sep 24, 2012 at 10:37 AM, TheOutlander theout...@gmail.com
wrote:

I'm not sure how to send a GET request with a JSON payload in C#. The
framework will throw an error when I try to get a RequestStream to write
to
it.

Can someone explain how I can emulate the CURL GET command (curl -GET
"http://localhost:9200/index/type/_search" -d "{ "query" : .... }") in
C#?

I was looking at NEST and it seems like it uses Thrift. Is there a
requirement that in C# I would need to use Thrift instead of an HTTP GET
Request with a payload??

Also, I've heard that GET with a payload is invalid, but read somewhere
that HTTP RFC says that it's ok.

Thanks,
Nick

--

--

--