|
| 1 | +# [# ElasticBNU - Vamos falar de Elasticsearch?](/kibana/elastic-bnu/2023-08-30/README.md) |
| 2 | +3º Encontro do Elastic Blumenau User Group - https://www.meetup.com/elastic-blumenau-user-group/events/294764876/ |
| 3 | +- Versão utilizada 8.9.1 |
| 4 | +- Este material utiliza o Docker para rodar os comandos |
| 5 | + |
| 6 | +## Analyzers e tokenizers |
| 7 | + |
| 8 | +``` |
| 9 | +
|
| 10 | +POST /_analyze |
| 11 | +{ |
| 12 | + "tokenizer": "standard", |
| 13 | + "text": "Exemplo padrão de analise de texto" |
| 14 | +} |
| 15 | +
|
| 16 | +POST /_analyze |
| 17 | +{ |
| 18 | + "tokenizer": "standard", |
| 19 | + "text": "[email protected] https://www.elastic.co/pt/blog/elastic-stack-7-13-1-released" |
| 20 | +} |
| 21 | +
|
| 22 | +POST /_analyze |
| 23 | +{ |
| 24 | + "tokenizer": "uax_url_email", |
| 25 | + "text": "[email protected] https://www.elastic.co/pt/blog/elastic-stack-7-13-1-released" |
| 26 | +} |
| 27 | +
|
| 28 | +GET /_analyze |
| 29 | +{ |
| 30 | + "tokenizer": "standard", |
| 31 | + "filter": [ |
| 32 | + { |
| 33 | + "type": "condition", |
| 34 | + "filter": [ "lowercase" ], |
| 35 | + "script": { |
| 36 | + "source": "token.getTerm().length() < 7" |
| 37 | + } |
| 38 | + } |
| 39 | + ], |
| 40 | + "text": "EXEMPLO DE ANALYZE COM CONDICAO NO FILTRO" |
| 41 | +} |
| 42 | +
|
| 43 | +GET /_analyze |
| 44 | +{ |
| 45 | + "tokenizer" : "standard", |
| 46 | + "filter" : [ |
| 47 | + "lowercase", |
| 48 | + "asciifolding" |
| 49 | + ], |
| 50 | + "text" : "Texto com acentos e outros caracteres. Aqui: imprescindível, diligência, índices, ações" |
| 51 | +} |
| 52 | +
|
| 53 | +``` |
| 54 | + |
| 55 | +### Stop words Analyzers e tokenizers |
| 56 | + |
| 57 | +``` |
| 58 | +
|
| 59 | +# removendo stop words https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-stop-tokenfilter.html |
| 60 | +
|
| 61 | +PUT /exemplo-stop-word |
| 62 | +{ |
| 63 | + "settings": { |
| 64 | + "index": { |
| 65 | + "analysis": { |
| 66 | + "filter": { |
| 67 | + "stop_words_brazilian": { |
| 68 | + "type": "stop", |
| 69 | + "stopwords": "_brazilian_" |
| 70 | + } |
| 71 | + }, |
| 72 | + "analyzer": { |
| 73 | + "sem-stop-words": { |
| 74 | + "filter": [ |
| 75 | + "asciifolding", |
| 76 | + "lowercase", |
| 77 | + "stop_words_brazilian" |
| 78 | + ], |
| 79 | + "tokenizer": "standard" |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | +} |
| 86 | +
|
| 87 | +POST /exemplo-stop-word/_analyze |
| 88 | +{ |
| 89 | + "analyzer": "sem-stop-words", |
| 90 | + "text": "Este é um exemplo de texto que eu gostaria de indexar." |
| 91 | +} |
| 92 | +
|
| 93 | +
|
| 94 | +``` |
| 95 | + |
| 96 | +### Sinônimos |
| 97 | + |
| 98 | +``` |
| 99 | +
|
| 100 | +# exemplo com sinonimos |
| 101 | +PUT /exemplo-sinonimos |
| 102 | +{ |
| 103 | + "settings": { |
| 104 | + "index": { |
| 105 | + "analysis": { |
| 106 | + "analyzer": { |
| 107 | + "trando-sinonimos": { |
| 108 | + "tokenizer": "standard", |
| 109 | + "filter": [ "synonym" ] |
| 110 | + } |
| 111 | + }, |
| 112 | + "filter": { |
| 113 | + "synonym": { |
| 114 | + "type": "synonym", |
| 115 | + "lenient": true, |
| 116 | + "synonyms": [ "tdc 2021, tdc, tdc connections => the developers conference" ] |
| 117 | + } |
| 118 | + } |
| 119 | + } |
| 120 | + } |
| 121 | + } |
| 122 | +} |
| 123 | +
|
| 124 | +POST /exemplo-sinonimos/_analyze |
| 125 | +{ |
| 126 | + "analyzer": "trando-sinonimos", |
| 127 | + "text": "tdc 2021" |
| 128 | +} |
| 129 | +
|
| 130 | +POST /exemplo-sinonimos/_analyze |
| 131 | +{ |
| 132 | + "analyzer": "trando-sinonimos", |
| 133 | + "text": "tdc" |
| 134 | +} |
| 135 | +
|
| 136 | +POST /exemplo-sinonimos/_analyze |
| 137 | +{ |
| 138 | + "analyzer": "trando-sinonimos", |
| 139 | + "text": "tdc connections" |
| 140 | +} |
| 141 | +
|
| 142 | +POST /exemplo-sinonimos/_analyze |
| 143 | +{ |
| 144 | + "analyzer": "trando-sinonimos", |
| 145 | + "text": "the developers conference" |
| 146 | +} |
| 147 | +
|
| 148 | +
|
| 149 | +``` |
| 150 | + |
| 151 | +### Stemmer |
| 152 | + |
| 153 | +``` |
| 154 | +
|
| 155 | +# exemplo com stemmer https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-stemmer-tokenfilter.html |
| 156 | +GET /_analyze |
| 157 | +{ |
| 158 | + "tokenizer": "standard", |
| 159 | + "filter": [ "stemmer" ], |
| 160 | + "text": "the foxes jumping quickly" |
| 161 | +} |
| 162 | +
|
| 163 | +PUT /exemplo-stemmer |
| 164 | +{ |
| 165 | + "settings": { |
| 166 | + "index": { |
| 167 | + "analysis": { |
| 168 | + "analyzer": { |
| 169 | + "exemplo-stemmer": { |
| 170 | + "tokenizer": "standard", |
| 171 | + "filter": [ "brazilian_stemmer" ] |
| 172 | + } |
| 173 | + }, |
| 174 | + "filter": { |
| 175 | + "brazilian_stemmer": { |
| 176 | + "type": "stemmer", |
| 177 | + "language": "brazilian" |
| 178 | + } |
| 179 | + } |
| 180 | + } |
| 181 | + } |
| 182 | + } |
| 183 | +} |
| 184 | +
|
| 185 | +POST /exemplo-stemmer/_analyze |
| 186 | +{ |
| 187 | + "analyzer": "exemplo-stemmer", |
| 188 | + "text": "Raffael, Raffaeis, Rafaela, Rafaelo" |
| 189 | +} |
| 190 | +
|
| 191 | +``` |
0 commit comments