Last active
May 4, 2024 16:31
-
-
Save luizgpsantos/f9b2f57ea13e7515b48a to your computer and use it in GitHub Desktop.
Revisions
-
luizgpsantos revised this gist
Feb 15, 2021 . 2 changed files with 13 additions and 32 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ // Ao [criar o índice][0], especifique um [analyzer customizado][1] responsável por tratar palavras // com caracteres especiais e o plural da lingua Portuguesa. Algumas palavras precisarão de uma // sintonia fina, o que pode ser feito através de [stemmer overrides][2]. Além disso, ao criar um // campo atribua o analyzer a ele. PUT produtos { @@ -51,7 +54,8 @@ PUT produtos/_doc/2 "titulo": "televisão" } // Faça uma busca utilizando um termo sem acento ou no plural. O resultado deve conter os // documentos com os termos acentuados e no singular. POST produtos/_search { @@ -73,10 +77,15 @@ POST produtos/_search } } // Para entender como o analyzer customizado está gerando os tokens, podemos utilizar a [analyze API][3]: GET produtos/_analyze { "text": ["televisões", "televisoes", "AVELAS"], "analyzer": "analyzer_plural_acentos" } [0]: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html [1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-custom-analyzer.html [2]: https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-stemmer-override-tokenfilter.html [3]: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,28 +0,0 @@ -
luizgpsantos revised this gist
Feb 15, 2021 . 1 changed file with 37 additions and 27 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,27 @@ // Ao [criar o índice](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html), especifique um [analyzer customizado](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-custom-analyzer.html) responsável por tratar palavras com caracteres especiais e o plural da lingua Portuguesa. Algumas palavras precisarão de uma sintonia fina, o que pode ser feito através de [stemmer overrides](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-stemmer-override-tokenfilter.html). Além disso, ao criar um campo atribua o analyzer a ele. PUT produtos { "settings": { "analysis": { "analyzer": { "analyzer_plural_acentos": { "tokenizer": "standard", "filter": [ "lowercase", "custom_stems", "stemmer_plural_portugues", "asciifolding" ] } }, "filter": { "custom_stems": { "type": "stemmer_override", "rules": [ "televisoes => televisão" ] }, "stemmer_plural_portugues": { "type": "stemmer", "name": "minimal_portuguese" @@ -24,49 +30,53 @@ curl -XPUT "http://localhost:9200/my_index" -d' } }, "mappings": { "properties": { "titulo": { "type": "text", "analyzer": "analyzer_plural_acentos" } } } } // Indexe os documentos, que podem conter acentos, maiusculas, plural, etc... PUT produtos/_doc/1 { "titulo": "avelãs" } PUT produtos/_doc/2 { "titulo": "televisão" } // Faça uma busca utilizando um termo sem acento ou no plural. O resultado deve conter os documentos com os termos acentuados e no singular. POST produtos/_search { "query": { "match": { "titulo": "televisoes" } } } // Outro exemplo de query... POST produtos/_search { "query": { "match": { "titulo": "AVELAS" } } } // Para entender como o analyzer customizado está gerando os tokens, podemos utilizar a [analyze API](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html): GET produtos/_analyze { "text": ["televisões", "televisoes", "AVELAS"], "analyzer": "analyzer_plural_acentos" } -
Luiz Guilherme Pais dos Santos revised this gist
Sep 21, 2015 . No changes.There are no files selected for viewing
-
luizgpsantos revised this gist
Sep 4, 2014 . 1 changed file with 10 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 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... 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... curl -XPOST "http://localhost:9200/my_index/_search" -d' { "query": { "match": { "titulo": "esta acoes" } } }' //Outro exemplo de query... 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. curl -XGET "http://localhost:9200/my_index/_analyze?analyzer=analyzer_customizado" -d' { está ações lugares melhorias nível Nível }' -
luizgpsantos revised this gist
Sep 4, 2014 . 1 changed file with 73 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 } -
luizgpsantos renamed this gist
Sep 4, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
luizgpsantos created this gist
Sep 4, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 }'