|
| 1 | +# [# Elastic - Curso Rápido](/kibana/elastic-bnu/curso-rapido/README.md) |
| 2 | +- Versão utilizada 8.12.2 |
| 3 | +- Este material utiliza o Docker para rodar os comandos |
| 4 | + |
| 5 | +## Indices, mappings e settings |
| 6 | + |
| 7 | +``` |
| 8 | +
|
| 9 | +GET /_cat/indices |
| 10 | +PUT /meu_primeiro_index |
| 11 | +DELETE /meu_primeiro_index |
| 12 | +
|
| 13 | +``` |
| 14 | + |
| 15 | + |
| 16 | +#### Criando um indice |
| 17 | + |
| 18 | +``` |
| 19 | +
|
| 20 | +PUT /autores |
| 21 | +{ |
| 22 | + "settings": { |
| 23 | + "number_of_replicas": "1", |
| 24 | + "number_of_shards": "2", |
| 25 | + "analysis": { |
| 26 | + "analyzer": { |
| 27 | + "meu_analyzer": { |
| 28 | + "type": "custom", |
| 29 | + "tokenizer": "standard", |
| 30 | + "filter": [ |
| 31 | + "lowercase", |
| 32 | + "asciifolding" |
| 33 | + ] |
| 34 | + } |
| 35 | + } |
| 36 | + } |
| 37 | + }, |
| 38 | + "mappings": { |
| 39 | + "dynamic": "strict", |
| 40 | + "_source": { |
| 41 | + "excludes": [ |
| 42 | + "todos" |
| 43 | + ] |
| 44 | + }, |
| 45 | + "properties": { |
| 46 | + "todos": { |
| 47 | + "type": "text", |
| 48 | + "analyzer": "meu_analyzer" |
| 49 | + }, |
| 50 | + "nome": { |
| 51 | + "type": "text", |
| 52 | + "copy_to": [ |
| 53 | + "todos" |
| 54 | + ] |
| 55 | + }, |
| 56 | + "descricao": { |
| 57 | + "type": "text", |
| 58 | + "copy_to": [ |
| 59 | + "todos" |
| 60 | + ] |
| 61 | + }, |
| 62 | + "email": { |
| 63 | + "type": "keyword", |
| 64 | + "copy_to": [ |
| 65 | + "todos" |
| 66 | + ] |
| 67 | + }, |
| 68 | + "site": { |
| 69 | + "type": "keyword", |
| 70 | + "copy_to": [ |
| 71 | + "todos" |
| 72 | + ] |
| 73 | + }, |
| 74 | + "especialidade": { |
| 75 | + "type": "text", |
| 76 | +
|
| 77 | + "copy_to": [ |
| 78 | + "todos" |
| 79 | + ] |
| 80 | + }, |
| 81 | + "data_nascimento": { |
| 82 | + "type": "date", |
| 83 | + "copy_to": [ |
| 84 | + "todos" |
| 85 | + ] |
| 86 | + } |
| 87 | + } |
| 88 | + } |
| 89 | +} |
| 90 | +
|
| 91 | +PUT /livros |
| 92 | +{ |
| 93 | + "settings": { |
| 94 | + "number_of_replicas": "1", |
| 95 | + "number_of_shards": "2", |
| 96 | + "analysis": { |
| 97 | + "analyzer": { |
| 98 | + "meu_analyzer": { |
| 99 | + "type": "custom", |
| 100 | + "tokenizer": "standard", |
| 101 | + "filter": ["lowercase", "asciifolding"] |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + }, |
| 106 | + "mappings": { |
| 107 | + "dynamic": "strict", |
| 108 | + "_source": { |
| 109 | + "excludes": [ |
| 110 | + "todos" |
| 111 | + ] |
| 112 | + }, |
| 113 | + "properties": { |
| 114 | + "todos": { |
| 115 | + "type": "text", |
| 116 | + "analyzer": "meu_analyzer" |
| 117 | + }, |
| 118 | + "titulo": { |
| 119 | + "type": "text", |
| 120 | + "copy_to": [ |
| 121 | + "todos" |
| 122 | + ] |
| 123 | + }, |
| 124 | + "descricao": { |
| 125 | + "type": "text", |
| 126 | + "copy_to": [ |
| 127 | + "todos" |
| 128 | + ] |
| 129 | + }, |
| 130 | + "assunto": { |
| 131 | + "type": "text", |
| 132 | + "copy_to": [ |
| 133 | + "todos" |
| 134 | + ] |
| 135 | + }, |
| 136 | + "autores": { |
| 137 | + "type": "text", |
| 138 | + "copy_to": [ |
| 139 | + "todos" |
| 140 | + ] |
| 141 | + }, |
| 142 | + "avaliacao": { |
| 143 | + "type": "float" |
| 144 | + } |
| 145 | + } |
| 146 | + } |
| 147 | +} |
| 148 | +
|
| 149 | +PUT /artigos |
| 150 | +{ |
| 151 | + "settings": { |
| 152 | + "number_of_replicas": "1", |
| 153 | + "number_of_shards": "2", |
| 154 | + "analysis": { |
| 155 | + "analyzer": { |
| 156 | + "meu_analyzer": { |
| 157 | + "type": "custom", |
| 158 | + "tokenizer": "standard", |
| 159 | + "filter": [ |
| 160 | + "lowercase", |
| 161 | + "asciifolding" |
| 162 | + ] |
| 163 | + } |
| 164 | + } |
| 165 | + } |
| 166 | + }, |
| 167 | + "mappings": { |
| 168 | + "dynamic": "strict", |
| 169 | + "_source": { |
| 170 | + "excludes": [ |
| 171 | + "todos" |
| 172 | + ] |
| 173 | + }, |
| 174 | + "properties": { |
| 175 | + "todos": { |
| 176 | + "type": "text", |
| 177 | + "analyzer": "meu_analyzer" |
| 178 | + }, |
| 179 | + "titulo": { |
| 180 | + "type": "text", |
| 181 | + "copy_to": [ |
| 182 | + "todos" |
| 183 | + ] |
| 184 | + }, |
| 185 | + "descricao": { |
| 186 | + "type": "text", |
| 187 | + "copy_to": [ |
| 188 | + "todos" |
| 189 | + ] |
| 190 | + }, |
| 191 | + "conteudo": { |
| 192 | + "type": "text", |
| 193 | + "copy_to": [ |
| 194 | + "todos" |
| 195 | + ] |
| 196 | + }, |
| 197 | + "autores": { |
| 198 | + "type": "text", |
| 199 | + "copy_to": [ |
| 200 | + "todos" |
| 201 | + ] |
| 202 | + }, |
| 203 | + "avaliacao": { |
| 204 | + "type": "float" |
| 205 | + } |
| 206 | + } |
| 207 | + } |
| 208 | +} |
| 209 | +
|
| 210 | +POST /_aliases |
| 211 | +{ |
| 212 | + "actions" : [ |
| 213 | + { "add" : { "indices" : ["autores", "artigos", "livros"], "alias" : "busca-geral" } }, |
| 214 | + { "add" : { "indices" : ["artigos", "livros"], "alias" : "busca-artigos-livros" } }, |
| 215 | + ] |
| 216 | +} |
| 217 | +
|
| 218 | +GET /_cat/indices?s=index |
| 219 | +
|
| 220 | +# verificando mappings e settings |
| 221 | +GET /autores/_mapping |
| 222 | +GET /autores/_settings |
| 223 | +
|
| 224 | +# verificando settings de todos os indices da busca geral |
| 225 | +GET /busca-geral/_settings/index.* |
| 226 | +GET /busca-geral/_settings |
| 227 | +GET /busca-geral/_mapping |
| 228 | +``` |
0 commit comments