Skip to content

Instantly share code, notes, and snippets.

@marcelitocs
Last active June 30, 2017 18:15
Show Gist options
  • Save marcelitocs/1cb437cf89450741b9617f762d8f35f8 to your computer and use it in GitHub Desktop.
Save marcelitocs/1cb437cf89450741b9617f762d8f35f8 to your computer and use it in GitHub Desktop.

Consultar a saúde do servidor:

GET /_cat/health?v

Está yellow?

PUT /.kibana/_settings
{
    "index": {
        "number_of_replicas": 0
    }
}

Script utilizado para criação do índice produtos:

PUT /produtos
{
  "settings": {
    "index": {
      "number_of_shards": 3,
      "number_of_replicas": 0
    }
  },
  "mappings": {
    "v1": {
      "_all": {
        "type": "text",
        "analyzer": "portuguese"
      },
      "properties": {
        "nome": {
          "fields": {
            "original": {
              "type": "keyword"
            }
          },
          "type": "text",
          "analyzer": "portuguese"
        },
        "tags": {
          "fields": {
            "original": {
              "type": "keyword"
            }
          },
          "type": "string",
          "index": "analyzed",
          "analyzer": "portuguese"
        },
        "preco": {
          "type": "float"
        }
      }
    }
  }
}

Inserir produtos no índice:

POST /produtos/v1/
{
  "nome": "Scala: Como escalar sua produtividade",
  "tags": ["impresso", "digital", "scala", "programação funcional", "computação", "imutabilidade"],
  "preco": 69.90
}

Mapeando datas

Exemplo (docs):

PUT /my_index
{
  "mappings": {
    "my_type": {
      "properties": {
        "date": {
          "type":   "date",
          "format": "basic_date_time"
        }
      }
    }
  }
}

Date formats can be customised, but if no format is specified then it uses the default (docs):

"strict_date_optional_time||epoch_millis"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment