Is there any way to pass search query in POST parameter rather than body?

Hello,

For complete functionality, UI framework I use needs query be passed in
POST parameters rather than body. Is there any way I can pass complete
query I would normally pass in the body in POST parameter.

Using GET and URI is not an option - I need full query DSL

Thank you,
Alex

--
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.

I found a partial answer. one can pass complete query in GET source
parameter. But the query I generate (with facet, facet filters + filtered
(based on selected facet values) query can rather long. I would be more
comfortable passing it as post parameter. I tried post with source
parameter but unfortunately it does not work:

{"error":"SearchPhaseExecutionException[Failed to execute phase
[query_fetch], total failure; shardFailures{[pguRRu2dTzKk_AMMcUO32w][award][0]: SearchParseException[[award][0]:
from[-1],size[-1]: Parse Failure [Failed to parse source [na]]]; nested:
ElasticSearchParseException[Failed to derive xcontent fromorg.elasticsearch.common.bytes.ChannelBufferBytesReference@61f0ab21];
}]","status":500}

On Wednesday, January 30, 2013 9:43:43 PM UTC-5, AlexR wrote:

Hello,

For complete functionality, UI framework I use needs query be passed in
POST parameters rather than body. Is there any way I can pass complete
query I would normally pass in the body in POST parameter.

Using GET and URI is not an option - I need full query DSL

Thank you,
Alex

--
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.

Sorry. I don't understand. What do you mean by POST?
This?

curl -XPOST 'http://localhost:9200/twitter/tweet/_search' -d '{
"query": {
"filtered" : {
"query" : {
"query_string" : {
"query" : "some query string here"
}
},
"filter" : {
"term" : { "user" : "kimchy" }
}
}
}
}
'

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

Le 31 janv. 2013 à 04:06, AlexR roytmana@gmail.com a écrit :

I found a partial answer. one can pass complete query in GET source parameter. But the query I generate (with facet, facet filters + filtered (based on selected facet values) query can rather long. I would be more comfortable passing it as post parameter. I tried post with source parameter but unfortunately it does not work:

{"error":"SearchPhaseExecutionException[Failed to execute phase [query_fetch], total failure; shardFailures {[pguRRu2dTzKk_AMMcUO32w][award][0]: SearchParseException[[award][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [na]]]; nested: ElasticSearchParseException[Failed to derive xcontent from org.elasticsearch.common.bytes.ChannelBufferBytesReference@61f0ab21]; }]","status":500}

On Wednesday, January 30, 2013 9:43:43 PM UTC-5, AlexR wrote:

Hello,

For complete functionality, UI framework I use needs query be passed in POST parameters rather than body. Is there any way I can pass complete query I would normally pass in the body in POST parameter.

Using GET and URI is not an option - I need full query DSL

Thank you,
Alex

--
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.

I mean passing query in form-encoded parameters via POST as supposed to
passing it in request body in raw
just like with get you can pass parameters via query string, with post you
can pass then form-encoded. web server (say servlet API) then would extract
them and present it to you as parameters

On Wed, Jan 30, 2013 at 10:27 PM, David Pilato david@pilato.fr wrote:

Sorry. I don't understand. What do you mean by POST?
This?

curl -XPOST 'http://localhost:9200/twitter/tweet/_search' -d '{
"query": {
"filtered" : {
"query" : {
"query_string" : {
"query" : "some query string here"
}
},
"filter" : {
"term" : { "user" : "kimchy" }
}
}
}
}
'

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

Le 31 janv. 2013 à 04:06, AlexR roytmana@gmail.com a écrit :

I found a partial answer. one can pass complete query in GET source
parameter. But the query I generate (with facet, facet filters + filtered
(based on selected facet values) query can rather long. I would be more
comfortable passing it as post parameter. I tried post with source
parameter but unfortunately it does not work:

{"error":"SearchPhaseExecutionException[Failed to execute phase
[query_fetch], total failure; shardFailures{[pguRRu2dTzKk_AMMcUO32w][award][0]: SearchParseException[[award][0]:
from[-1],size[-1]: Parse Failure [Failed to parse source [na]]];
nested: ElasticSearchParseException[Failed to derive xcontent fromorg.elasticsearch.common.bytes.ChannelBufferBytesReference@61f0ab21];
}]","status":500}

On Wednesday, January 30, 2013 9:43:43 PM UTC-5, AlexR wrote:

Hello,

For complete functionality, UI framework I use needs query be passed in
POST parameters rather than body. Is there any way I can pass complete
query I would normally pass in the body in POST parameter.

Using GET and URI is not an option - I need full query DSL

Thank you,
Alex

--
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.

--
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.

I don't think you can. See Jörg answer: https://groups.google.com/d/msg/elasticsearch/SzF0LhiVvqk/htn52x3xgmoJ

That said, you can do something like:

curl -XGET http://localhost:9200/_search?source=YOUR_JSON_HERE

curl 'localhost:9200/_search?source={"query":{"term":{"user":"kimchy"}}}'

Does it help?

Le 31 janv. 2013 à 04:31, Alex Roytman roytmana@gmail.com a écrit :

I mean passing query in form-encoded parameters via POST as supposed to passing it in request body in raw
just like with get you can pass parameters via query string, with post you can pass then form-encoded. web server (say servlet API) then would extract them and present it to you as parameters

On Wed, Jan 30, 2013 at 10:27 PM, David Pilato david@pilato.fr wrote:
Sorry. I don't understand. What do you mean by POST?
This?

curl -XPOST 'http://localhost:9200/twitter/tweet/_search' -d '{
"query": {
"filtered" : {
"query" : {
"query_string" : {
"query" : "some query string here"
}
},
"filter" : {
"term" : { "user" : "kimchy" }
}
}
}
}
'

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

Le 31 janv. 2013 à 04:06, AlexR roytmana@gmail.com a écrit :

I found a partial answer. one can pass complete query in GET source parameter. But the query I generate (with facet, facet filters + filtered (based on selected facet values) query can rather long. I would be more comfortable passing it as post parameter. I tried post with source parameter but unfortunately it does not work:

{"error":"SearchPhaseExecutionException[Failed to execute phase [query_fetch], total failure; shardFailures {[pguRRu2dTzKk_AMMcUO32w][award][0]: SearchParseException[[award][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [na]]]; nested: ElasticSearchParseException[Failed to derive xcontent from org.elasticsearch.common.bytes.ChannelBufferBytesReference@61f0ab21]; }]","status":500}

On Wednesday, January 30, 2013 9:43:43 PM UTC-5, AlexR wrote:
Hello,

For complete functionality, UI framework I use needs query be passed in POST parameters rather than body. Is there any way I can pass complete query I would normally pass in the body in POST parameter.

Using GET and URI is not an option - I need full query DSL

Thank you,
Alex

--
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.

--
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.

I am already doing it with GET and source parameter and it works well. One
huge benefit is that size and start (and hopefully sort but have not tested
it yet) url parameters override whatever is in source={...} - big help
integrating with UI components that manage paging and generate these http
parameters

Now the problem is that for all practical purposes uri length is limited to
2000 characters so GET may very well fail with bigger queries (as I said
query with facet based "filtered", facets themselves, filters.... can get
pretty long plus of course url-encoding of all spaces and {} )

I wish the same functionality were available via POST. Couldn't ES check
encoding in POST header and if it is *application/x-www-form-urlencoded *just
extract encoded parameters and use source parameter just like it does with
GET?

Do you think I should put an enhancement request into Git?

--
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.

I had a similar issue.
I manged to get the parameters from the post by doing:

@Override

public void handleRequest(final RestRequest request, final RestChannel
channel) {

Map<String,String> params = new HashMap<String, String>();
RestUtils.decodeQueryString(request.content().toUtf8(), 0, params);
String paramValue = params.get("parameter");

//DO SOMETHING

}

Notice that the json query you want to pass in doesn't need to be encoded
on the client side (with an Http.GET it needs to be)

Hope that helps

On Thursday, January 31, 2013 10:03:33 AM UTC-8, AlexR wrote:

I am already doing it with GET and source parameter and it works well. One
huge benefit is that size and start (and hopefully sort but have not tested
it yet) url parameters override whatever is in source={...} - big help
integrating with UI components that manage paging and generate these http
parameters

Now the problem is that for all practical purposes uri length is limited
to 2000 characters so GET may very well fail with bigger queries (as I said
query with facet based "filtered", facets themselves, filters.... can get
pretty long plus of course url-encoding of all spaces and {} )

I wish the same functionality were available via POST. Couldn't ES check
encoding in POST header and if it is *application/x-www-form-urlencoded *just
extract encoded parameters and use source parameter just like it does with
GET?

Do you think I should put an enhancement request into Git?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/bddfebfc-519f-4320-b8aa-024849ae0c31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thanks Kelsey that could be useful. I managed to get my UI framework
(ExtJS) to play better with POST so I am not dependent on having to use GET
any more

On Wed Nov 26 2014 at 5:54:43 PM Kelsey Hamer kelsey.hamer@gmail.com
wrote:

I had a similar issue.
I manged to get the parameters from the post by doing:

@Override

public void handleRequest(final RestRequest request, final RestChannel
channel) {

Map<String,String> params = new HashMap<String, String>();
RestUtils.decodeQueryString(request.content().toUtf8(), 0, params);
String paramValue = params.get("parameter");

//DO SOMETHING

}

Notice that the json query you want to pass in doesn't need to be encoded
on the client side (with an Http.GET it needs to be)

Hope that helps

On Thursday, January 31, 2013 10:03:33 AM UTC-8, AlexR wrote:

I am already doing it with GET and source parameter and it works well.
One huge benefit is that size and start (and hopefully sort but have not
tested it yet) url parameters override whatever is in source={...} - big
help integrating with UI components that manage paging and generate these
http parameters

Now the problem is that for all practical purposes uri length is limited
to 2000 characters so GET may very well fail with bigger queries (as I said
query with facet based "filtered", facets themselves, filters.... can get
pretty long plus of course url-encoding of all spaces and {} )

I wish the same functionality were available via POST. Couldn't ES check
encoding in POST header and if it is *application/x-www-form-urlencoded *just
extract encoded parameters and use source parameter just like it does with
GET?

Do you think I should put an enhancement request into Git?

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/tDmS4ABPag0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/bddfebfc-519f-4320-b8aa-024849ae0c31%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/bddfebfc-519f-4320-b8aa-024849ae0c31%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAAY7rMS4sh%2BDHF%2BYTCOs6OT3Q7iZfCDOR2o_ct9adqP7dPTH%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.