Is is possible to use different query languages (such as lucene, script, ..) in a search?

example:

GET filebeat*/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "stream": "stderr"
          }
        },
        {
          "range": {
            "@timestamp": {
              "gte": "now-24h"
            }
          }
        }
      ],
      "must_not": [
        {
           "q": "message:Foo+Bar",
           "language": "lucene"
         }
      ]
    }
  }
}

Would something like this be possible?

I know I could convert this lucene syntax in the ES Query DSL, but I'd like to use several queries defined in Lucene syntax, programmatically

The query string query uses a Lucene syntax if this is what you are looking for.

Thanks, yes I know I can do ?q=message:Foo+Bar as query string, but I'd like to wrap multiple lucene searches inside a bigger query like above

Not sure if I got your question right but this?

GET /_search
{
    "query": {
        "query_string" : {
            "query" : "message:Foo+Bar"
        }
    }
}

Based on doc here: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html

Wow, thanks, that's what I needed

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