Elasticsearch
Aggregations
E eu?2
Waldemar Neto @waldemarnt
http://walde.co/
Quanto mais, melhor!3
Vamos falar de que?4
Vamos falar de que?5
AGGREGATIONS
Elasticsearch
” Banon. Shay
7
“Elasticsearch is a search server based on Lucene. It provides
a distributed, multitenant-capable full-text search engine
with a RESTful web interface and schema-free JSON
documents. Elasticsearch is developed in Java and is released
as open source under the terms of the Apache License.”
8 Quem usa?
Fonte: https://www.elastic.co/use-cases
O Apache Lucene9
REST API10
Termos comuns
● Cluster
● Node
● Index
● Shard
● Replica
● Type
● Document
● Term
11
Índice invertido, onde a magia acontece
Term Doc_1 Doc_2 Doc_3
Waldemar x x
Bicicleta x x x
Avião x
12
1. Score
1.1. Bicicleta 3
1.2. Waldemar 2
1.3. Avião 1
Overview do ecossistema13
CLUSTER
NODE
SHARD REPLICA
Escalonamento14
CLUSTER
NODE 1 - MASTER
SHARD1
REPLICA
3
NODE 2
SHARD2
REPLICA
1
NODE 3
SHARD3
REPLICA
2
Indexando um documento15
CLUSTER
NODE 1 - MASTER
SHARD1
REPLICA
3
NODE 2
SHARD2
REPLICA
1
NODE 3
SHARD3
REPLICA
2
CLIENT
Buscando documentos16
CLUSTER
NODE 1 - MASTER
SHARD1
REPLICA
3
NODE 2
SHARD2
REPLICA
1
NODE 3
SHARD3
REPLICA
2
CLIENT
Interagindo com o servidor17
Estrutura de dados
1. Index
2. Type
3. Document
18
1 2
3
RESTful Response
Na linha do RESTful
index
type
document reference(id)
19
parameters
Mapping
▹ NoSql style
▹ Pode ser criado manualmente
▹ Pode ser alterado dinamicamente
20
O que o elasticsearch me oferece?
▹ Queries
▹ Filtros
▹ Geolocation
▹ Aggregations
▹ Full Text Search
▹ Escalabilidade
▹ Comunicação RESTful
21
O que são aggregations?
”
Com aggregations é possível ter um overview
dos dados. Ao invés de olhar por documentos
individuais. É possível analisar e classificar
completamente um grupo de dados.
23
Aggregations na vida real!
24
Bora ver na prática?
25 Buckets
Itens a serem agrupados26
Agrupando por marcas27
Resultado28
Agrupando por tamanhos29
Resultado30
31 Metrics
32 Valor médio das cervejas
Tipos de Buckets33
● Children Aggregation
● Date Histogram Aggregation
● Date Range Aggregation
● Filter Aggregation
● Filters Aggregation
● Geo Distance Aggregation
● GeoHash grid Aggregation
● Global Aggregation
● Histogram Aggregation
● IPv4 Range Aggregation
● Missing Aggregation
● Nested Aggregation
● Range Aggregation
● Reverse nested Aggregation
● Sampler Aggregation
● Significant Terms
Aggregation
● Terms Aggregation
Tipos de Metrics
● Avg Aggregation
● Cardinality Aggregation
● Extended Stats Aggregation
● Geo Bounds Aggregation
● Geo Centroid Aggregation
● Max Aggregation
● Min Aggregation
● Percentiles Aggregation
● Percentile Ranks Aggregation
● Scripted Metric Aggregation
34
● Stats Aggregation
● Sum Aggregation
● Top hits Aggregation
● Value Count Aggregation
35
36
37
38
39
40
Onde aprende?
42
43
44
E ERAS ISSO
Thanks!
Perguntas?
https://github.com/waldemarnt
https://twitter.com/waldemarnt
https://fb.com/waldemarnt
http://walde.co
45

Elasticsearch Aggregations