Skip to content

Instantly share code, notes, and snippets.

@thyagobr
Forked from luizgpsantos/Exemplo completo
Last active November 19, 2020 12:52
Show Gist options
  • Save thyagobr/e416f9d4dd273fc5463d to your computer and use it in GitHub Desktop.
Save thyagobr/e416f9d4dd273fc5463d to your computer and use it in GitHub Desktop.

Revisions

  1. thyagobr renamed this gist Feb 9, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @luizgpsantos luizgpsantos revised this gist Sep 4, 2014. 1 changed file with 10 additions and 11 deletions.
    21 changes: 10 additions & 11 deletions Exemplo completo
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    //Cria o índice especificando quais os analyzer ele tem
    //Além disso especifica que o campo "titulo" do tipo "seu_tipo" utiliza o analyzer recem criado

    PUT /my_index
    curl -XPUT "http://localhost:9200/my_index" -d'
    {
    "settings": {
    "analysis": {
    @@ -33,41 +33,40 @@ PUT /my_index
    }
    }
    }
    }
    }'

    //Indexa os seus documentos, que podem conter acentos, maiusculas, etc...

    PUT my_index/seu_tipo/1
    curl -XPUT "http://localhost:9200/my_index/seu_tipo/1" -d'
    {
    "titulo": "está ações lugares melhorias nível Nível"
    }
    }'

    //Realiza uma busca por um termo sem acento, ç, etc...

    POST my_index/_search
    curl -XPOST "http://localhost:9200/my_index/_search" -d'
    {
    "query": {
    "match": {
    "titulo": "esta acoes"
    }
    }
    }
    }'

    //Outro exemplo de query...

    POST my_index/_search
    curl -XPOST "http://localhost:9200/my_index/_search" -d'
    {
    "query": {
    "match": {
    "titulo": "nivel"
    }
    }
    }

    }'

    // Isso daqui é usado só para endender como o seu analyzer está funcionando.

    GET /my_index/_analyze?analyzer=analyzer_customizado
    curl -XGET "http://localhost:9200/my_index/_analyze?analyzer=analyzer_customizado" -d'
    {
    está ações lugares melhorias nível Nível
    }
    }'
  3. @luizgpsantos luizgpsantos revised this gist Sep 4, 2014. 1 changed file with 73 additions and 0 deletions.
    73 changes: 73 additions & 0 deletions Exemplo completo
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,73 @@
    //Cria o índice especificando quais os analyzer ele tem
    //Além disso especifica que o campo "titulo" do tipo "seu_tipo" utiliza o analyzer recem criado

    PUT /my_index
    {
    "settings": {
    "analysis": {
    "analyzer": {
    "analyzer_customizado": {
    "tokenizer": "standard",
    "filter": [
    "lowercase",
    "stemmer_plural_portugues",
    "asciifolding"
    ]
    }
    },
    "filter": {
    "stemmer_plural_portugues": {
    "type": "stemmer",
    "name": "minimal_portuguese"
    }
    }
    }
    },
    "mappings": {
    "seu_tipo": {
    "properties": {
    "titulo": {
    "type": "string",
    "analyzer": "analyzer_customizado"
    }
    }
    }
    }
    }

    //Indexa os seus documentos, que podem conter acentos, maiusculas, etc...

    PUT my_index/seu_tipo/1
    {
    "titulo": "está ações lugares melhorias nível Nível"
    }

    //Realiza uma busca por um termo sem acento, ç, etc...

    POST my_index/_search
    {
    "query": {
    "match": {
    "titulo": "esta acoes"
    }
    }
    }

    //Outro exemplo de query...

    POST my_index/_search
    {
    "query": {
    "match": {
    "titulo": "nivel"
    }
    }
    }


    // Isso daqui é usado só para endender como o seu analyzer está funcionando.

    GET /my_index/_analyze?analyzer=analyzer_customizado
    {
    está ações lugares melhorias nível Nível
    }
  4. @luizgpsantos luizgpsantos renamed this gist Sep 4, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. @luizgpsantos luizgpsantos created this gist Sep 4, 2014.
    28 changes: 28 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    curl -XPUT "http://localhost:9200/my_index" -d'
    {
    "settings": {
    "analysis": {
    "analyzer": {
    "analyzer_customizado": {
    "tokenizer": "standard",
    "filter": [
    "lowercase",
    "stemmer_plural_portugues",
    "asciifolding"
    ]
    }
    },
    "filter": {
    "stemmer_plural_portugues": {
    "type": "stemmer",
    "name": "minimal_portuguese"
    }
    }
    }
    }
    }'

    curl -XGET "http://localhost:9200/my_index/_analyze?analyzer=analyzer_customizado" -d'
    {
    está ações lugares melhorias nível Nível
    }'