Jax-rs rest api using stored template


I'm trying to figure how I can create a jax-rs REST call to search elastic search using a stored template.
for the moment I'm doing a POST , using the http body to put the data in. Somehting like this :


and as a body :
"file": "count",
"params": {
"grp_by_field": "objecttype.keyword"

where count is the moustache file. Is this correct ? This works in jmeter, but I'm getting a http 400 status back when
executing this using jax-rs :
String queryString="{ "file": "count" , "params": { "grp_by_field"="objecttype.keyword" } }";

	Response r = client

In any case, it doesn't feel right to do a POST when querying data... Any ideas on how to do this ?


ok, now it works, it was not grp_by_field= but grp_by_field:

remains the question that : is it correct to the use the api like this : submitting a post to execute a query ?

It's better to use a GET indeed as we state in the documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html

That said, some libraries don't support GET with body. That's why we support in that case both GET and POST verbs.

ok tnx !

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