Skip to content

Instantly share code, notes, and snippets.

@reinaldocoelho
Last active August 29, 2019 14:51
Show Gist options
  • Save reinaldocoelho/ce22f922683e74ab27ecabada69bc376 to your computer and use it in GitHub Desktop.
Save reinaldocoelho/ce22f922683e74ab27ecabada69bc376 to your computer and use it in GitHub Desktop.
Exemplos ElasticSearch

Lista todos os indices

GET /_cat/indices?v

Lista todos os registros de um indice

GET /<INDEX>/_search?pretty=true&q=*:*

Apresenta o mapeamento de um indice

GET /<INDEX>/_mapping

Exemplo de busca (QUERYSTRING) "enContact Busca Global de e-mails" em vários campos

GET /<INDEX>/_search
{
    "query": {
        "query_string": {
            "fields": [
                "from",
                "destinataries",
                "subject",
                "body",
                "formAnswers"
            ],
            "query": "campeao"
        }
  }
}

Exemplo de busca (MATCH)

GET /<INDEX>/_search
{
    "query": {
        "match": {
            "body": "campeao"
        }
  }
}

Como fazer teste de um analisador customizado

GET /<INDEX>/_analyze
{
  "analyzer": "<CUSTOM_ANALYSER_NAME>", 
  "text": "ações lugares melhorias nível Nível"
}

Como apagar um indice

DELETE /<INDEX>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment