Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marceloserpa/6f26d5af1524a04afc7d7cb4da7cb22b to your computer and use it in GitHub Desktop.
Save marceloserpa/6f26d5af1524a04afc7d7cb4da7cb22b to your computer and use it in GitHub Desktop.

GET _cat/indices

Create the template:

PUT _index_template/blogposts
{
  "index_patterns": ["post-*"],
  "template": {
    "settings": {
      "number_of_shards": 1
    },
    "mappings": {
      "_source": {
        "enabled": true
      },
      "properties": { 
        "name":     { "type": "text"  }, 
        "age":      { "type": "integer" }  
      } 
    },
    "aliases": {
      "mydata": { }
    }
  }
}

Added documents for month 08

POST post-2020-08/_doc/1
{
  "name":     "Marcelo", 
  "age":       31
}
POST post-2020-08/_doc/2
{
  "name":     "Marcelo2", 
  "age":       31
}
POST post-2020-08/_doc/3
{
  "name":     "Marcelo3", 
  "age":       31
}

Added documents for month 09

POST post-2020-09/_doc/4
{
  "name":     "Marcelo4", 
  "age":       31
}
POST post-2020-09/_doc/5
{
  "name":     "Marcelo5", 
  "age":       31
}

Searh on multiples indexes using wilcard

GET post-2020-*/_search 
{
  "query": {
    "match_all": {}
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment