introducción a elasticsearch
TRANSCRIPT
![Page 1: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/1.jpg)
Elastic SearchUh ! Elastic Search
@marcossegovia
![Page 2: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/2.jpg)
Shay Banon liberó la primera versión de ES en 2010
Motor de búsqueda basado en Apache Lucene
Vamos a escalar
![Page 3: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/3.jpg)
?
Apache Lucene
Librería hecha en Java útil para cualquier aplicación que requiera indexado y búsqueda a texto completoOpen sourceCon la gente de Apache Foundation dando soporteFuncionando desde el 1999
![Page 4: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/4.jpg)
Cómo se está vendiendo?
![Page 5: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/5.jpg)
Cómo se está vendiendo?
![Page 6: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/6.jpg)
Cómo se está vendiendo?
![Page 7: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/7.jpg)
Características
Búsquedas sobre Apache Lucene (Motor búsqueda Java)
Full Text Search
Distribuido
Multi-Entorno
API REST
JSON Request/Response
![Page 8: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/8.jpg)
Asentemos la terminología
Realtime Engine significa Propagación
Cluster significa Colección de Nodes
Node significa un server que forma parte de UN Cluster
Index significa Colección de Documents bajo mismos o distintos Types
Type significa Categoría/Entidad/Clase
Document significa Unidad Básica de Información
![Page 9: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/9.jpg)
Básicamente para que?
Indexar toda la información para que pueda ser buscada de manera óptima.
Esta vez VOLCANDO la información, real e idéntica.Sí, ES soporta cualquier DataType
![Page 10: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/10.jpg)
DataTypes
StringFull text stringKeywords string
Numericlonginteger
Date
Boolean
ComplexObjectArray
Nested
Geo
Specialized
… Geo PointGeo Shape
IPv4…
string…
![Page 11: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/11.jpg)
![Page 12: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/12.jpg)
Searching
Leaf query clauseBúsqueda de un valor en un campo
Compound query clause
Combinan Leaf queries u otras Compound queries de manera lógica
![Page 13: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/13.jpg)
Searching
Query Context
Filter Context
“¿Como de bien ‘matchea’ este Document en mi query clause?”
“¿Matchea este Document en mi query clause?”
Performance: Filtros usados frecuentemente serán cacheados por ElasticSearch
“filter”: { }
“query”: { }
![Page 14: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/14.jpg)
Searching
Full text queries
match estándar query
match_phrase como match, pero con múltiples palabras
match_phrase_prefix como match_phrase pero intenta autocompletar la última palabra
multi_match estándar query contra múltiples campos
![Page 15: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/15.jpg)
Searching
No sólo full text queries…term level query
geo querycompound query
joining querytermrange
boolconstant_score…
…
nested
……
existshas_child
![Page 16: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/16.jpg)
![Page 17: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/17.jpg)
Ejemplo molón
Referencia: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html
POST /_search
Filter Context
No afecta al scoring total
Query Context
Calculará un scoring sobre los que cumplan
CompoundQuery
LeafQuery
![Page 18: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/18.jpg)
Pero…
no os he dicho toda la verdad.
Y la verdad es…
QUE VOY A GANAR LA PORRA !
nah… la verdad es que existen los Analyzers
![Page 19: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/19.jpg)
Analyzers
El proceso de analysis es simplemente llevar el texto a términos o tokens hacia el índice de ES.
El proceso lo aplica un analyzer específico cuando:
Se indexan nuevos documentos
Se realiza una búsqueda
El analyzer a utilizar se puede especificar en la misma query o en el mapping del índice
![Page 20: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/20.jpg)
Analyzers
Standard Analyzer
![Page 21: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/21.jpg)
AggregationsMisma query, danos internet
![Page 22: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/22.jpg)
![Page 23: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/23.jpg)
![Page 24: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/24.jpg)
![Page 25: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/25.jpg)
![Page 26: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/26.jpg)
![Page 27: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/27.jpg)
![Page 28: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/28.jpg)
Distribución y Escalabilidad
![Page 29: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/29.jpg)
Distribución y Escalabilidad
ElasticSearch from the bottom up - EuroPython 2014Lucene index - Elastic index 13:30
Planifica los shardings con previsión 16:17
Por defecto: 1 índice se crea con 5 shards y 1 réplica
El número de replicas se puede cambiar dinámicamente, los shards no
Por tanto, 10 shards.
![Page 30: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/30.jpg)
Todo esto y más en…
Effective Elastic Search https://gist.github.com/MarcosSegovia/c4f9585d0450791470485c68514acc05
Migración de Sphinx a Elastic Search https://gist.github.com/MarcosSegovia/edcc2b766eede8ddc2409e59f10e43c3
Directorio en Postman con múltiples ejemplos.
![Page 31: Introducción a ElasticSearch](https://reader034.vdocumento.com/reader034/viewer/2022042605/58f1a3d01a28abd2388b459d/html5/thumbnails/31.jpg)
Por cada pregunta se crea un Order nuevo para mañana
Si queréis más, saco el Postman