Skip to content

Instantly share code, notes, and snippets.

@TomonoriSoejima
Last active November 6, 2020 12:24
Show Gist options
  • Save TomonoriSoejima/f2738653941c3b2f57385bf185f67eb4 to your computer and use it in GitHub Desktop.
Save TomonoriSoejima/f2738653941c3b2f57385bf185f67eb4 to your computer and use it in GitHub Desktop.
time format test
DELETE a2

PUT a2
{
  "mappings": {
    "a": {
      "properties": {
        "created": {
          "type": "date"
        },
        "name": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "star": {
          "type": "long"
        }
      }
    }
  }
}

PUT a2/a/1
{
  "name" : "test1",
  "created" : 201710192005,
  "star" : 5
}

# data should be like this in time stamp.
PUT a2/a/2
{
  "name" : "test2",
  "created" : 1508893628000,
  "star" : 7
}



PUT a2/a/3
{
  "name" : "test3",
  "created" : 201710192005,
  "star" : 7
}


GET a2/_search
{
  "aggs": {
    "2": {
      "date_histogram": {
        "field": "created"
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment