N
N
Niko True2017-10-12 19:11:59
elasticsearch
Niko True, 2017-10-12 19:11:59

How to write queries with special characters in ElasticSearch?

Hello. Question in the following, it is necessary to select the data it is admissible for the last 10 minutes. There are services that are called. It is necessary to group by these services and count the number of their outputs, as well as add the number of errors that are found through the filter. The filter uses special characters and is not searched for by them. ES ignores them. An example of what is already there:

spoiler
GET _search?
{
  "query": {
    "filtered": {
      "query": {
        "query_string": {
          "query": "*"
        }
      },
      "filter": {
        "bool": {
          "must": [
            {
              "range": {
                "datetime": {
                  "gte": "now-10m",
                  "lte": "now"
                }
              }
            }
          ]
        }
      }
    }
  },
  "size": 0,
  "aggs": {
    "services": {
      "terms": {
        "field": "info.raw",
        "size": 500,
        "order": {
          "myerrors": "desc"
        }
      },
      "aggs": {
        "myerrors": {
          "filter": {
            "query": {
              "query_string": { 
                "analyzer": "whitespace",
                "query": "error-3"
              }
            }
          }
        }
      }
    }
  }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Niko True, 2017-10-13
@buloshnik

Alexey Cheremisin Hello, can you help?

C
chupasaurus, 2017-10-12
@chupasaurus

Escaping via \, e.g. \*
Lucene syntax

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question