Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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\": ..., ... }" }
like image 637
Johan Hirsch Avatar asked Dec 03 '25 15:12

Johan Hirsch


1 Answers

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" } } }"""
like image 98
sksamuel Avatar answered Dec 06 '25 15:12

sksamuel