Page 1
Symfony2 + Elasticsearchmaking the world a better place
Page 2
E eu?
2
Waldemar Neto @waldemarnt
http://walde.co/
Page 3
Vamos falar de que?
3
Page 4
Vamos falar de que?
4
Page 5
Voltando 3 anos no tempo
5
Page 7
Buscas avançadas
7
Page 8
Elasticsearchbusca em tempo real
Page 9
‘’“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.”
Banon. Shay
9
Page 10
10
Quem usa?
Fonte: https://www.elastic.co/use-cases
Page 11
O Apache Lucene
11
Page 13
Como isso funciona?
1.Ecossistema
13
Page 14
Termos comuns
● Cluster● Node● Index● Shard● Replica● Type● Document● Term
14
Page 15
Índice invertido, onde a magia acontece
Term Doc_1 Doc_2 Doc_3
Waldemar x x
Bicicleta x x x
Avião x
15
1. Score1.1. Bicicleta 31.2. Waldemar 21.3. Avião 1
Page 16
Overview do ecossistema
16
CLUSTER
NODE
SHARD REPLICA
Page 17
Escalonamento
17
CLUSTER
NODE 1 - MASTER
SHARD1 REPLICA3
NODE 2
SHARD2 REPLICA1
NODE 3
SHARD3 REPLICA2
Page 18
Indexando um documento
18
CLUSTER
NODE 1 - MASTER
SHARD1 REPLICA3
NODE 2
SHARD2 REPLICA1
NODE 3
SHARD3 REPLICA2CLIENT
Page 19
Buscando documentos
19
CLUSTER
NODE 1 - MASTER
SHARD1 REPLICA3
NODE 2
SHARD2 REPLICA1
NODE 3
SHARD3 REPLICA2CLIENT
Page 20
Falhas no cluster
20
CLUSTER
NODE 1 - MASTER
SHARD1 REPLICA3
NODE 2
SHARD2 REPLICA1
NODE 3
SHARD3 REPLICA2
Page 21
Cluster Health
● Verde● Amarelo● Vermelho
21
Page 22
Interagindo com o servidor
22
Page 23
Estrutura de dados
1. Index2. Type3. Document
23
1 2
3
RESTful Response
Page 24
Na linha do RESTful
index
type
document reference(id)
24parameters
Page 25
Mapping
▣ NoSql style▣ Pode ser criado manualmente▣ Pode ser alterado dinamicamente
25
Page 26
O que o elasticsearch me oferece?
▣ Queries▣ Filtros▣ Geolocation▣ Aggregations▣ Full Text Search▣ Escalabilidade▣ Comunicação RESTful
26
Page 28
Symfony.com website28
Page 29
Integrando Symfony e Elasticsearch
29
FosElasticaBundle
Page 30
Configurando FosElasticaBundle
30
Page 31
Sincronizando dados
31
Page 33
Entidades Doctrine
Trabalhando junto com Doctrine
33
User
Posts
Page 35
Buscando uma entidade
35
Page 36
Criando uma busca
36
Page 37
Montando Queries
37
Page 38
BoolQuery com Match em Json38
Page 39
BoolQuery com MatchQuery usando ElasticaBundle39
Page 40
40
Renderizando resultado
Page 42
100.000+Documentos indexados
200msTempo médio de resposta para as requisições
30.000+Dispositivos consultando
42
Page 47
Thanks!Perguntas?
https://github.com/waldemarnt
https://twitter.com/waldemarnt
https://fb.com/waldemarnt
http://walde.co47