Johan Hirsch February 2016

elastic4s build query from JSON source

Is there a way to build a query in elastic4s from a JSON string?

For example, something like:

client.execute { "{ \"query\": ..., \"aggs\": ..., ... }" }

Answers


monkjack February 2016

It doesn't support a truly raw query in the sense of passing a string to client.execute. This is because the execute method wraps the Java client, and the Java client provides seperate methods per request type.

But you can pass in a raw query string, so something like:

search in "*" types("users", "tweets") limit 5 rawQuery {
 +  """{ "prefix": { "bands": { "prefix": "coldplay", "boost": 5.0, "rewrite": "yes" } } }"""

Post Status

Asked in February 2016
Viewed 1,607 times
Voted 6
Answered 1 times

Search




Leave an answer