简体   繁体   中英

what happens when performing a match query on a date field

Why can I perform a query of the following type:

GET myindex/_search
{
  "query": {
    "bool" : {
      "must": [
        {"match": {"@timestamp": "454545645656"}}
      ]
    } 
  }
}

when the field type is the following one?

"mappings": {
  "fluentd": {
    "properties": {
      "@timestamp": {
        "type": "date"
      },

does it make sense? Does the query value passes the analyzer and compares the field against what?

No, even you are using the match query on date field and match are analyzed means it goes through the same analyzers applied at index time on the field. As explained in official ES doc .

But as explained in the official ES doc on date datatype .

Queries on dates are internally converted to range queries on this long representation

You can test it yourself by using the explain=true param on your search query. More info about explain API can be found here .

I did this for your search query and you can see in the result(explanation part) it shows the range query on the date field.

URL:- /_search?explain=true

"hits": [
            {
                "_shard": "[date-index][0]",
                "_node": "h2H2MJd5T5-b1cUSkHVHcw",
                "_index": "date-index",
                "_type": "_doc",
                "_id": "1",
                "_score": 1.0,
                "_source": {
                    "@timestamp": "454545645656"
                },
                "_explanation": {
                    "value": 1.0,
                "description": "@timestamp:[454545645656 TO 454545645656]", --> see range query
                "details": []
                }
            }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM