elasticsearch aggregations

45
Elasticsearch Aggregations

Upload: waldemar-neto

Post on 09-Apr-2017

172 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Elasticsearch Aggregations

Elasticsearch Aggregations

Page 2: Elasticsearch Aggregations

E eu?2

Waldemar Neto @waldemarnt

http://walde.co/

Page 3: Elasticsearch Aggregations

Quanto mais, melhor!3

Page 4: Elasticsearch Aggregations

Vamos falar de que?4

Page 5: Elasticsearch Aggregations

Vamos falar de que?5

AGGREGATIONS

Page 6: Elasticsearch Aggregations

Elasticsearch

Page 7: Elasticsearch Aggregations

” 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.”

Page 8: Elasticsearch Aggregations

8 Quem usa?

Fonte: https://www.elastic.co/use-cases

Page 9: Elasticsearch Aggregations

O Apache Lucene9

Page 10: Elasticsearch Aggregations

REST API10

Page 11: Elasticsearch Aggregations

Termos comuns

● Cluster● Node● Index● Shard● Replica● Type● Document● Term

11

Page 12: Elasticsearch Aggregations

Í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. Score1.1. Bicicleta 31.2. Waldemar 21.3. Avião 1

Page 13: Elasticsearch Aggregations

Overview do ecossistema13

CLUSTER

NODE

SHARD REPLICA

Page 14: Elasticsearch Aggregations

Escalonamento14

CLUSTER

NODE 1 - MASTER

SHARD1 REPLICA3

NODE 2

SHARD2 REPLICA1

NODE 3

SHARD3 REPLICA2

Page 15: Elasticsearch Aggregations

Indexando um documento15

CLUSTER

NODE 1 - MASTER

SHARD1 REPLICA3

NODE 2

SHARD2 REPLICA1

NODE 3

SHARD3 REPLICA2CLIENT

Page 16: Elasticsearch Aggregations

Buscando documentos16

CLUSTER

NODE 1 - MASTER

SHARD1 REPLICA3

NODE 2

SHARD2 REPLICA1

NODE 3

SHARD3 REPLICA2CLIENT

Page 17: Elasticsearch Aggregations

Interagindo com o servidor17

Page 18: Elasticsearch Aggregations

Estrutura de dados

1. Index2. Type3. Document

18

1 2

3

RESTful Response

Page 19: Elasticsearch Aggregations

Na linha do RESTful

index

type

document reference(id)

19

parameters

Page 20: Elasticsearch Aggregations

Mapping

▹ NoSql style▹ Pode ser criado manualmente▹ Pode ser alterado dinamicamente

20

Page 21: Elasticsearch Aggregations

O que o elasticsearch me oferece?

▹ Queries▹ Filtros▹ Geolocation▹ Aggregations▹ Full Text Search▹ Escalabilidade▹ Comunicação RESTful

21

Page 22: Elasticsearch Aggregations

O que são aggregations?

Page 23: Elasticsearch 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

Page 24: Elasticsearch Aggregations

Aggregations na vida real!

24

Bora ver na prática?

Page 25: Elasticsearch Aggregations

25 Buckets

Page 26: Elasticsearch Aggregations

Itens a serem agrupados26

Page 27: Elasticsearch Aggregations

Agrupando por marcas27

Page 28: Elasticsearch Aggregations

Resultado28

Page 29: Elasticsearch Aggregations

Agrupando por tamanhos29

Page 30: Elasticsearch Aggregations

Resultado30

Page 31: Elasticsearch Aggregations

31 Metrics

Page 32: Elasticsearch Aggregations

32 Valor médio das cervejas

Page 33: Elasticsearch Aggregations

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

Page 34: Elasticsearch Aggregations

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

Page 35: Elasticsearch Aggregations

35

Page 36: Elasticsearch Aggregations

36

Page 37: Elasticsearch Aggregations

37

Page 38: Elasticsearch Aggregations

38

Page 39: Elasticsearch Aggregations

39

Page 40: Elasticsearch Aggregations

40

Page 41: Elasticsearch Aggregations

Onde aprende?

Page 42: Elasticsearch Aggregations

42

Page 43: Elasticsearch Aggregations

43

Page 44: Elasticsearch Aggregations

44

E ERAS ISSO

Page 45: Elasticsearch Aggregations

Thanks!Perguntas?

https://github.com/waldemarnt

https://twitter.com/waldemarnt

https://fb.com/waldemarnt

http://walde.co

45