1
Thiago Souza
Support Engineer @ Elastic
Elasticsearch 5.0
2
Elasticsearch 5.0
Um pouco sobre mim
• Desenvolvedor há mais de 10 anos
• Utilizo o Elasticsearch desde 2010
(em produção desde v0.90.0)
•Recentemente iniciei como Support Engineer
na Elastic
3
Elastic Overview
70,000+
Community
Members
estatísticas desde 2012, quando a empresa foi criada
70M+
Products
Downloads
2,400+
Subscription
Customers
We aim to help you make your data usable in real time to
power mission critical applications that solve today’s real problems
44
Global Customer Base
Tech
Finance
Telco
Consumer
5
Elasticsearch is an Open
Source (Apache 2),
Distributed, RESTful, Search
Engine built on top of Lucene.
http://www.elasticsearch.org - 2011
6
Apache LuceneTM is a high-
performance, full-featured text
search engine library written entirely
in Java.
https://lucene.apache.org/core
7
• Full-featured text search engine
• Library written entirely in Java.
‒Uma biblioteca Java off-line, acessada localmente.
Elasticsearch 5.0
Apache Lucene: Full Text Search
Id Texto Ids Termo
1 Amanhã vai chover no Rio de Janeiro 1 amanha
2 Rio de Janeiro tem muita praia! 1 chov
2 praia
1,2 rio
...
Inverted Index
8
• Full-featured text search engine
• Library written entirely in Java.
‒Uma biblioteca Java off-line, acessada localmente.
Elasticsearch 5.0
Apache Lucene: Full Text Search
Id Texto Ids Termo
1 Amanhã vai chover no Rio de Janeiro 1 amanha
2 Rio de Janeiro tem muita praia! 1 chov
2 praia
1,2 rio
...
Inverted Index
"Amanhã" => "amanha"
"chover" => "chov"
9
Elasticsearch 5.0
Apache Lucene: Aggregations
Orientado a Tuplas Orientado a Colunas
id Nome Idade Peso id Nome Idade Peso
1 João 34 811 João 34 81
X
2 Maria 51 652 Maria 51 65
3 José 53 763 José 53 76
Agregações mais rápidas AVG(Idade) = 46 SUM(Peso) = 222
10
Elasticsearch 5.0
Elasticsearch
$ curl -XPOST 'localhost:9200/twitter/tweet/' -d '{
"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "trying out Elasticsearch"
}'
HTTP + JSON
Um index no Elasticsearch é composto por 1
ou mais shards e cada shard com 0 ou mais
réplicas
11
Elasticsearch 5.0
Elasticsearch: v0.90.0 (2013)
• Alta Disponibilidade
• Escalabilidade Horizontal
• API RESTful
• Busca Full Text
• Busca Multifaceted:
‒Term
‒Histogram
‒Range
‒etc...
12
13
Elasticsearch 5.0
Elastic Stack 5.0
• Nova identidade visual
• Release unificado
• X-Pack: Pacote de Plugins
14
1515
Segurança
Elasticsearch 5.0
Elasticsearch
● Java Security Manager para plugins.
● Sandboxed Scripting (Painless).
● Verificação de Jarhell.
● Suporte a Site plugins removido.
1616
Apache Lucene 6.0
Muda fundamentalmente como números são tratados. Lucene 6.0 guarda
dados numéricos em uma estrutura chamada k-dimensional tree.
Na prática, isso significa que, se tratando de números:
Elasticsearch 5.0
Elasticsearch
● Ocupa metade do espaço em disco e
também requer menos memória.
● Indexação 2x mais rápida.
● Busca 25% mais rápida.
● Permite suporte a números gigantes
como IPv6.
https://www.elastic.co/blog/lucene-points-6.0
1717
Apache Lucene 6.0
Fundamentalmente muda o algoritmo de scoring.
Lucene 6.0 utiliza o algoritmo Okapi BM25 para ordenação por relevância.
Antes era TF-IDF.
Elasticsearch 5.0
Elasticsearch
1818
Apache Lucene 6.0
Fundamentalmente muda o algoritmo de scoring.
Lucene 6.0 utiliza o algoritmo Okapi BM25 para ordenação por relevância.
Antes era TF-IDF.
Elasticsearch 5.0
Elasticsearch
https://www.elastic.co/elasticon/conf/2016/sf/improve
d-text-scoring-with-bm25
1919
Wait-For-Refresh
O novo recurso Wait-For-Refresh vai permitir que uma operação de escrita
bloqueie o retorno até que o próximo refresh regular aconteça.
Elasticsearch 5.0
Elasticsearch
PUT my-type/my-type/my-id?refresh=true /** <= forces a refresh **/
{
"foo" : "bar"
}
PUT my-type/my-type/my-id?refresh=wait_for /** <= blocks until next refresh **/
{
"foo" : "bar"
}
2020
Elasticsearch 5.0
Elasticsearch
Index Shrinking
Permite reduzir o número de shards de um index.
POST my-source-index/_shrink/my-target-index /** target index must not exist!! **/
{
"settings" : {
"index.number_of_shards" : 1,
"index.number_of_replicas" : 0
"index.codec" : "best_compression"
}
}
2121
● Restrição 1: O número de shards menor tem que ser um fator do número
de shards maior. Exemplos:
– Um index com 8 shards pode ser reduzido para 4, 2 ou 1.
– Um index com 15 shards pode ser reduzido para 5, 3, ou 1.
– Um index com 5 shards não pode ser reduzido para 3.
Elasticsearch 5.0
Elasticsearch: Index Shrinking
0 1
2 3
0
1
SHRINK
2222
● Restrição 2: O operação de Shrink acontece fisicamente em apenas um nó
do cluster. Sendo assim é preciso existir um nó no cluster com espaço
suficiente para a operação.
Elasticsearch 5.0
Elasticsearch: Index Shrinking
0 1
2 3
0
COPY
004
2323
● Dica: O processo de Shrink é significativamente mais rápido quando o
filesystem suporta hard links.
Elasticsearch 5.0
Elasticsearch: Index Shrinking
0
COPY
1 0
1
24
Muito Obrigado!
DÚVIDAS?
Thiago Souza
thiago@elastic.co
https://elastic.co/v5
https://elastic.co/docs
https://elastic.co/blog
https://discuss.elastic.co
https://meetup.com/Brasil-Elastic-Fantastics

Elasticsearch 5.0

  • 1.
    1 Thiago Souza Support Engineer@ Elastic Elasticsearch 5.0
  • 2.
    2 Elasticsearch 5.0 Um poucosobre mim • Desenvolvedor há mais de 10 anos • Utilizo o Elasticsearch desde 2010 (em produção desde v0.90.0) •Recentemente iniciei como Support Engineer na Elastic
  • 3.
    3 Elastic Overview 70,000+ Community Members estatísticas desde2012, quando a empresa foi criada 70M+ Products Downloads 2,400+ Subscription Customers We aim to help you make your data usable in real time to power mission critical applications that solve today’s real problems
  • 4.
  • 5.
    5 Elasticsearch is anOpen Source (Apache 2), Distributed, RESTful, Search Engine built on top of Lucene. http://www.elasticsearch.org - 2011
  • 6.
    6 Apache LuceneTM isa high- performance, full-featured text search engine library written entirely in Java. https://lucene.apache.org/core
  • 7.
    7 • Full-featured textsearch engine • Library written entirely in Java. ‒Uma biblioteca Java off-line, acessada localmente. Elasticsearch 5.0 Apache Lucene: Full Text Search Id Texto Ids Termo 1 Amanhã vai chover no Rio de Janeiro 1 amanha 2 Rio de Janeiro tem muita praia! 1 chov 2 praia 1,2 rio ... Inverted Index
  • 8.
    8 • Full-featured textsearch engine • Library written entirely in Java. ‒Uma biblioteca Java off-line, acessada localmente. Elasticsearch 5.0 Apache Lucene: Full Text Search Id Texto Ids Termo 1 Amanhã vai chover no Rio de Janeiro 1 amanha 2 Rio de Janeiro tem muita praia! 1 chov 2 praia 1,2 rio ... Inverted Index "Amanhã" => "amanha" "chover" => "chov"
  • 9.
    9 Elasticsearch 5.0 Apache Lucene:Aggregations Orientado a Tuplas Orientado a Colunas id Nome Idade Peso id Nome Idade Peso 1 João 34 811 João 34 81 X 2 Maria 51 652 Maria 51 65 3 José 53 763 José 53 76 Agregações mais rápidas AVG(Idade) = 46 SUM(Peso) = 222
  • 10.
    10 Elasticsearch 5.0 Elasticsearch $ curl-XPOST 'localhost:9200/twitter/tweet/' -d '{ "user" : "kimchy", "post_date" : "2009-11-15T14:12:12", "message" : "trying out Elasticsearch" }' HTTP + JSON Um index no Elasticsearch é composto por 1 ou mais shards e cada shard com 0 ou mais réplicas
  • 11.
    11 Elasticsearch 5.0 Elasticsearch: v0.90.0(2013) • Alta Disponibilidade • Escalabilidade Horizontal • API RESTful • Busca Full Text • Busca Multifaceted: ‒Term ‒Histogram ‒Range ‒etc...
  • 12.
  • 13.
    13 Elasticsearch 5.0 Elastic Stack5.0 • Nova identidade visual • Release unificado • X-Pack: Pacote de Plugins
  • 14.
  • 15.
    1515 Segurança Elasticsearch 5.0 Elasticsearch ● JavaSecurity Manager para plugins. ● Sandboxed Scripting (Painless). ● Verificação de Jarhell. ● Suporte a Site plugins removido.
  • 16.
    1616 Apache Lucene 6.0 Mudafundamentalmente como números são tratados. Lucene 6.0 guarda dados numéricos em uma estrutura chamada k-dimensional tree. Na prática, isso significa que, se tratando de números: Elasticsearch 5.0 Elasticsearch ● Ocupa metade do espaço em disco e também requer menos memória. ● Indexação 2x mais rápida. ● Busca 25% mais rápida. ● Permite suporte a números gigantes como IPv6. https://www.elastic.co/blog/lucene-points-6.0
  • 17.
    1717 Apache Lucene 6.0 Fundamentalmentemuda o algoritmo de scoring. Lucene 6.0 utiliza o algoritmo Okapi BM25 para ordenação por relevância. Antes era TF-IDF. Elasticsearch 5.0 Elasticsearch
  • 18.
    1818 Apache Lucene 6.0 Fundamentalmentemuda o algoritmo de scoring. Lucene 6.0 utiliza o algoritmo Okapi BM25 para ordenação por relevância. Antes era TF-IDF. Elasticsearch 5.0 Elasticsearch https://www.elastic.co/elasticon/conf/2016/sf/improve d-text-scoring-with-bm25
  • 19.
    1919 Wait-For-Refresh O novo recursoWait-For-Refresh vai permitir que uma operação de escrita bloqueie o retorno até que o próximo refresh regular aconteça. Elasticsearch 5.0 Elasticsearch PUT my-type/my-type/my-id?refresh=true /** <= forces a refresh **/ { "foo" : "bar" } PUT my-type/my-type/my-id?refresh=wait_for /** <= blocks until next refresh **/ { "foo" : "bar" }
  • 20.
    2020 Elasticsearch 5.0 Elasticsearch Index Shrinking Permitereduzir o número de shards de um index. POST my-source-index/_shrink/my-target-index /** target index must not exist!! **/ { "settings" : { "index.number_of_shards" : 1, "index.number_of_replicas" : 0 "index.codec" : "best_compression" } }
  • 21.
    2121 ● Restrição 1:O número de shards menor tem que ser um fator do número de shards maior. Exemplos: – Um index com 8 shards pode ser reduzido para 4, 2 ou 1. – Um index com 15 shards pode ser reduzido para 5, 3, ou 1. – Um index com 5 shards não pode ser reduzido para 3. Elasticsearch 5.0 Elasticsearch: Index Shrinking 0 1 2 3 0 1 SHRINK
  • 22.
    2222 ● Restrição 2:O operação de Shrink acontece fisicamente em apenas um nó do cluster. Sendo assim é preciso existir um nó no cluster com espaço suficiente para a operação. Elasticsearch 5.0 Elasticsearch: Index Shrinking 0 1 2 3 0 COPY 004
  • 23.
    2323 ● Dica: Oprocesso de Shrink é significativamente mais rápido quando o filesystem suporta hard links. Elasticsearch 5.0 Elasticsearch: Index Shrinking 0 COPY 1 0 1
  • 24.