3

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

For example, something like:

client.execute { "{ \"query\": ..., \"aggs\": ..., ... }" }
Johan Hirsch
  • 557
  • 4
  • 21

1 Answers1

3

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" } } }"""
sksamuel
  • 16,154
  • 8
  • 60
  • 108