SlideShare une entreprise Scribd logo
1  sur  64
Nadhiir Rosun / @nads_rosun
E l a s t i c s e a r c h a n d S y m f o n y
31/03/2017
A p r a c t i c a l a p p r o a c h
2
1. Introduction
2. ES versus RDBMS
3. Talking to ES
4. Architecture
5. Querying ES
6. Case study
7. Conclusions
3
Introduction
Highly scalable open-source full-text search and
analytics engine
Allows you to store, search, and analyze big volumes of
data quickly and in near real time.
Build on top of Apache Lucene
¬ Popular/powerfull full-text search engine library
Developed in Java
4
Introduction / Projects using ES
Wikipedia
¬ Full-text search
¬ Highlighted search snippets
¬ Search-as-you-type
¬ Did-you-mean suggestions
The Guardian
¬ Real–time analytics of visitor logs
Stack Overflow
¬ Full-text search with geolocation queries
¬ Find related questions and answers
GitHub
¬ Query 130 billion lines of code
5
Introduction / Use case 1
An online store
Customers can search for products
Big volume of products / large amount of transactions
Product catalog to be full-text search, autocomplete
suggestions, did-you-mean suggestions
6
Introduction / Use case 2
Analytics/business intelligence needs
Collect log and transaction data
 Analyze the data to look for trends, statistics &
summarizations
Build custom dashboard to visualize aspects of the data
7
1. Introduction
2. ES versus RDBMS
3. Talking to ES
4. Architecture
5. Querying ES
6. Case study
7. Conclusions
8
ES versus RDBMS
Document oriented (NoSQL)
Schema free
Easily distributed & scalable
All fields indexed
Comprehensive and powerfull RESTful API
Advanced search
¬ Full-text search
¬ Aggregations
9
ES versus RDBMS / Teminology
Relational database ES
Database Index
Table Type
Row Document
SELECT GET
INSERT PUT/POST
UPDATE PUT/POST
DELETE DELETE
10
1. Introduction
2. ES versus RDBMS
3. Talking to ES
4. Architecture
5. Querying ES
6. Case study
7. Conclusions
11
Talking to ES / Installation
https://www.elastic.co/downloads/elasticsearch
Check if ES is running
¬ http://localhost:9200/
{
"name" : "Cp8oag6",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
"version" : {
"number" : "5.3.0",
"build_hash" : "f27399d",
"build_date" : "2016-03-30T09:51:41.449Z",
"build_snapshot" : false,
"lucene_version" : "6.4.1"
},
"tagline" : "You Know, for Search"
}
12
Talking to ES
RESTful API with JSON over HTTP
¬ Curl
¬ Guzzle
¬ Kibana
PHP Client
¬ Official php client
- https://github.com/elastic/elasticsearch-php
¬ Elastica
- https://github.com/ruflin/Elastica
Framework specific
¬ Symfony : FOSElasticaBundle
- https://github.com/FriendsOfSymfony/FOSElasticaBundle
¬ Drupal 8 : Elasticsearch Connector
- https://www.drupal.org/project/elasticsearch_connector
13
Talking to ES / Kibana
14
Talking to ES / Index a document
PUT /[index]/[type]/[doc_id]
Request
PUT /providers/accomodation/1
{
"name" : "Beaurivage Appartments",
"about" : "Room or studio accommodation in the centre of the village",
"city" : "Grand Baie",
"star" : 3,
"facility" : ["Internet", "Pool", “Television”, "Parking"]
}
15
Talking to ES / Index a document
Response
{
"_index": "providers",
"_type": "accomodation",
"_id": "1",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"created": true
}
16
Talking to ES / Retrieve a document
GET /[index]/[type]/[doc_id]
Request
GET /providers/accomodation/1
17
Talking to ES / Retrieve a document
Response
{
"_index": "providers",
"_type": "accomodation",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"name": "Beaurivage Appartments",
"about": "Room or studio accommodation in the centre of the village",
"city": "Grand Baie",
"star": 3,
"facility": ["Internet", "Pool", "Television", "Parking"]
}
}
18
Talking to ES / Update a document
PUT /[index]/[type]/[doc_id]
Request
PUT /providers/accomodation/1
{
"name" : "Beaurivage Appartments",
"about" : "Room or studio accommodation in the centre of the village",
"city" : "Grand Baie",
"star" : 4,
"facility" : ["Internet", "Pool", “Television”, "Parking"]
}
19
Talking to ES / Update a document
Response
{
"_index": "providers",
"_type": "accomodation",
"_id": "1",
"_version": 2,
"result": “updated",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"created": true
}
20
Talking to ES / Delete a document
DELETE /[index]/[type]/[doc_id]
Request
DELETE /providers/accomodation/1
21
Talking to ES / Delete a document
Response
{
"found": true,
"_index": "providers",
"_type": "accomodation",
"_id": "1",
"_version": 3,
"result": "deleted",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
}
}
22
1. Introduction
2. ES versus RDBMS
3. Talking to ES
4. Architecture
5. Querying ES
6. Case study
7. Conclusions
23
Architecture / Cluster
A collection of one or more nodes (servers)
¬ Sharing the same cluster name
¬ Working together to share data/workload
Perfectly fine to have a cluster with only a single node
24
Architecture / Node
A single server that is part of your cluster
¬ A single instance of ES
Master node
¬ One node is elected as MASTER
¬ Manage cluster-wide changes
25
Architecture / Shard
Think of shards as containers for data
¬ Allows to horizontally split/scale your content volume
¬ Allows to distribute and parallelize operations(Performance)
Primary shard :
¬ Document is first indexed on a single primary shard
Replica shard :
¬ Is just a copy of a primary shard
¬ Protect against hardware failure / share server load
26
Architecture / Index
A collection of documents with similar characteristics
¬ An index for :
- Customer data
- Product catalog
- Order data
Create an index
PUT /providers
{
"settings" : {
"number_of_shards" : 3,
"number_of_replicas" : 1
}
}
27
Architecture / Type
A logical category/partition of your index
Within an index, you can define one or more types
Has a list of fields mapping
A type is defined for documents that have a set of
common fields
¬ Product index with perishable type and non-perishable type √
¬ Blog index with article type and log type ×
28
Architecture / Document
A basic unit of information that can be indexed
A JSON object stored in a single shard
Uniquely identified by its index, type and id
{
"_index": "providers",
"_type": "accomodation",
"_id": "1",
"_version": 1,
"_source": {
"name": "Beaurivage Appartments",
"about": "Room or studio accommodation in the centre of the village",
"city": "Grand Baie",
"star": 3,
"facility": ["Internet", "Pool", "Television", "Parking"]
}
}
29
Architecture / Mapping
ES automatically creates a mapping/schema
GET /[index]/_mapping/[type]
GET /providers/_mapping/accomodation
{
"providers": {
"mappings": {
"accomodation": {
"properties": {
"about": { …, "type": "text", … },
"city": { …, "type": "text", … },
"facility": { …, "type": "keyword", … },
"name": { …, "type": "text", … },
"stars": { …, "type": "long“, … }
}
…
}
30
1. Introduction
2. ES versus RDBMS
3. Talking to ES
4. Architecture
5. Querying ES
6. Case study
7. Conclusions
31
Querying ES / Query DSL
JSON-style domain-specific language to execute queries
GET /providers/accommodation/_search
{
"query": {
"bool": {
"must": [
{ "match": { “name": " Appartments " }},
{ "match": { “about": " Appartments " }}
],
"filter": [
{ "term": { " facility ": “Internet" }},
{ "range": { “stars": { "gte": “3" }}}
]
}
}
}
32
Querying ES / Query DSL
Match all
¬ Simply matches all documents
- SELECT * FROM providers.accommodation
GET /providers/accommodation/_search
{
"query": {
"match_all": {}
}
}
33
Querying ES / Query DSL
Match
¬ Query a field
- SELECT * FROM providers.accommodation p WHERE p.name =
‘Beaurivage’
GET /providers/accommodation/_search
{
"query": {
"match": {
“name” : “Beaurivage”
}
}
}
34
Querying ES / Query DSL
Range
¬ Find numbers or dates that fall into a specified range
- SELECT * FROM providers.accommodation p WHERE p.stars > 3
GET /providers/accommodation/_search
{
"query": {
"range" : {
“stars" : {
"gte" : 3,
}
}
}
}
35
Querying ES / Query DSL
Term
¬ Finds documents that contain the exact term
- SELECT * FROM providers.accommodation p WHERE p.facilities =
‘Internet’
GET /providers/accommodation/_search
{
"query": {
"term" : { “facility" : “Internet" }
}
}
36
Querying ES / Query DSL
Bool
¬ Combine query clauses
- Must :
› The clause must appear in matching documents
› Contribute to score
- Filter :
› The clause must appear in matching documents
› Scoring is ignored
GET /providers/accommodation/_search
{
"query": {
"bool": {
"must": [ … ],
"filter": [ … ]
}
}
}
37
Querying ES / Query DSL
Pagination
¬ From
- Similar to offset in sql
¬ Size
- Similar to limit in sql
¬ SELECT * FROM providers.accommodation p LIMIT 10 OFFSET 15
GET /providers/accommodation/_search
{
"query": {
“match_all” : {}
},
“from” : 15,
“size” : 10
}
38
Querying ES / Full-text search
Structured search
¬ Something either belongs in the set or it does not
¬ Simply includes or excludes documents
¬ Does not worry about document relevance or scoring
¬ Very fast and cachable
Full-text search
¬ Finds how well a documents match the search keywords
¬ Analysis/Inverted index
¬ Each document gets a score
¬ Return documents sorted by relevance
39
Querying ES / Full-text search
Case study : 2 documents
{
"name" : "Beaurivage Appartments",
"about" : "Room or studio accommodation in the centre of the village",
"city" : "Grand Baie",
"star" : 3,
"facility" : ["Internet", "Pool", “Television”, "Parking"]
},
{
"name" : "Hotel Allamanda",
"about" : "Hotel room in front of the best lagoon of the island.",
"city" : "Tamarin",
"star" : 5,
"facility" : ["Internet", “Beach", “Telephone”, "Parking"]
},
40
Querying ES / Full-text search
Case study : Full-text search query
GET /providers/accomodation/_search
{
"query": {
"match": {
"about": "Room accomodation"
}
}
}
41
Querying ES / Full-text search
Response
{ "took": 218, "timed_out": false,
"_shards": { "total": 5, "successful": 5, "failed": 0 },
"hits": {
"total": 2, "max_score": 0.28488502,
"hits": [
{
"_index": "providers", "_type": "accomodation", "_id": "1",
"_score": 0.28488502,
"_source": { … }
},
{
"_index": "providers", "_type": "accomodation", "_id": "2",
"_score": 0.24257512,
"_source": { … }
}
}
}
42
Querying ES / Query DSL
Inverted Index
¬ Designed to allow very fast full-text searches
¬ Consists of :
- a list of all the unique words that appear in any document
- For each word, a list of the documents in which it appears.
1.The quick brown fox jumped over the lazy dog
1.Quick brown foxes leap over lazy dogs in summer
43
Querying ES / Query DSL
Split into separate tokens
List of unique tokens
List in which document each
term appears
Notice:
- Quick and quick appear as
separate terms
- fox and foxes share the same
root word
44
Querying ES / Query DSL
Analyzers
¬ Character Filters
- Tidy up string
- Strip out HTML and ‘&’
¬ Tokenizer
- Split into tokens/terms
- Every whitespace/punctuation
¬ Token Filters
- Can change the tokens
› Lowercase
› Add synonyms
› Remove stopwords (a, and, the…)
Token Filters
Tokenizer
Character
filters
45
1. Introduction
2. ES versus RDBMS
3. Talking to ES
4. Architecture
5. Querying ES
6. Case study
7. Conclusions
46
Case study / SF3 resto search engine
Creating a simple restaurant search engine
¬ Full-text search
¬ Facets
¬ Pagination
Techno :
¬ Symfony 3
- FOSElasticaBundle
- PagerBundle
¬ Elasticsearch
47
Case study / SF3 resto search engine
48
Case study / SF3 resto search engine
MySQLES
Restaurant
- Name
- About
- City
- facilities
Restaurant
- Name
- About
- City
- photo
- facilities
App 1. New/Update/Delete
Serializer
2. Doctrine object
3. JSON object
Indexing
49
Case study / SF3 resto search engine
MySQLES
Restaurant
- Name
- About
- City
- facilities
Restaurant
- Name
- About
- City
- photo
- facilities
App
Finder
5.Doctrine object
2. JSON object
1. Search
3,4. Fetch from db
Searching
50
Case study / SF3 resto search engine
Installing the bundles with composer
your_project/composer.json
"require": {
…
“friendsofsymfony/elastica-bundle": "^3.0",
"ruflin/elastica": "3.1.1 as 2.99.0",
"white-october/pagerfanta-bundle": "dev-master",
}
51
Case study / SF3 resto search engine
Register the bundles
your_project/app/AppKernel.php
$bundles = [
…
new FOSElasticaBundleFOSElasticaBundle(),
new WhiteOctoberPagerfantaBundleWhiteOctoberPagerfantaBundle(),
];
52
Case study / SF3 resto search engine
Configuration
¬ Add ES server address in ‘parameters.yml’
your_project/app/config/parameters.yml
parameters:
…
elastica_host: localhost
elastica_port: 9200
¬ Create/import new configuration file ‘fos_elastica.yml’
your_project/app/config/config.yml
imports:
…
- { resource: fos_elastica.yml }
53
Case study / SF3 resto search engine
your_project/app/config/fos_elastica.yml
fos_elastica:
clients:
default: { host: "%elastica_host%", port: "%elastica_port%" }
indexes:
prov:
client: default
types:
restaurant:
mappings:
name: ~
about: ~
city: ~
facilities:
type: keyword
persistence:
driver: orm
model: AppBundleEntityRestaurant
finder: ~
provider: ~
listener: ~
54
Case study / SF3 resto search engine
Persistence
¬ Defines how FOSElasticaBundle will index your docs depending
on your symfony entities
Driver
¬ Driver to use (ORM)
Model
¬ Allow to define an ES doc from a symfony entity
Finder
¬ Search interface (deserialize JSON objects into doctrine objects)
Provider
¬ Indexing interface (serialize doctrine objects to JSON objects)
Listener
¬ List of listeners for which the indexing is called
- Default : insert, update & delete
55
Case study / SF3 resto search engine
File structure
56
Case study / SF3 resto search engine
Create Entity ‘Restaurant’
your_project/src/AppBundle/Entity/Restaurant.php
class Restaurant
{
protected $id;
protected $name;
protected $about;
protected $city;
protected $photo;
protected $facilities;
//getters and setters
}
57
Case study / SF3 resto search engine
Index the doctrine objects to ES
¬ Uses the provider defined in fos_elastica.yml
¬ Serialize Doctrine objects to JSON using the Symfony Serializer
component
- Uses the predefined mapping in this process
From the command line
php bin/console fos:elastica:populate
58
Case study / SF3 resto search engine
Create the form model
¬ Mapped to the FormType
¬ Contain two properties
- title
- facilities
your_project/src/AppBundle/Model/SearchModel.php
class SearchModel
{
protected $title; //string
protected $facilities; //array
//getters and setters
}
59
Case study / SF3 resto search engine
Create the form type
¬ Contain two fields : title, facilities
your_project/src/AppBundle/Form/Type/SearchType.php
$builder
->add('title', null, array(
'required' => false,
))
->add('facilities', ChoiceType::class, array(
'choices' => array(
'Internet' => 'Internet',
'Parking' => 'Parking',
'Toilet' => 'Toilet',
'Beach' => 'Beach',
'Card Payment' => 'Card Payment',
),
'expanded' => true,
'multiple' => true,
))
->add('search', SubmitType::class);
60
Case study / SF3 resto search engine
Bundle everything in your search action
your_project/src/AppBundle/Controller/DefaultController.php
$perPage = 8;
// Create form
$searchModel = new SearchModel();
$searchForm = $this->createForm(SearchType::class, $searchModel);
// Get form data
$searchForm->handleRequest($request);
$searchModel = $searchForm->getData();
// Perform query in ES
$elasticaManager = $this->container->get('fos_elastica.manager');
$results = $elasticaManager->getRepository('AppBundle:Restaurant')->search($searchModel);
// Pagination
$adapter = new ArrayAdapter($results);
$pager = new Pagerfanta($adapter);
$pager->setMaxPerPage($perPage);
$pager->setCurrentPage($page);
// return results, pager and form to your template
61
Case study / SF3 resto search engine
ES search repository
your_project/src/AppBundle/Repository/SearchRepository.php
$boolQuery = new ElasticaQueryBoolQuery();
// Search Field name
$queryName = new ElasticaQueryMatch();
$queryName->setFieldQuery('name', $searchModel->getTitle());
$boolQuery->addShould($queryName);
// Search Field about
$queryAbout = new ElasticaQueryMatch();
$queryAbout->setFieldQuery('about', $searchModel->getTitle());
$queryAbout->setFieldParam('about', 'analyzer', 'english');
$boolQuery->addShould($queryAbout);
…
// Terms
if (count($searchModel->getFacilities()) > 0) {
$tagsQuery = new ElasticaQueryTerms();
$tagsQuery->setTerms('facilities', $searchModel->getFacilities());
$boolQuery->addMust($tagsQuery);
}
$query = ElasticaQuery::create($boolQuery);
62
1. Introduction
2. ES versus RDBMS
3. Talking to ES
4. Architecture
5. Querying ES
6. Case study
7. Conclusions
63
Conclusion
Suggester API
Message broker (RabbitMQ)
extension interactive
14, avenue des Lataniers
72238 Quatre Bornes
Thank you 

Contenu connexe

Tendances

Let's Build an Inverted Index: Introduction to Apache Lucene/Solr
Let's Build an Inverted Index: Introduction to Apache Lucene/SolrLet's Build an Inverted Index: Introduction to Apache Lucene/Solr
Let's Build an Inverted Index: Introduction to Apache Lucene/SolrSease
 
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...Edureka!
 
ActiveRecord Callbacks & Observers, Season 2
ActiveRecord Callbacks & Observers, Season 2ActiveRecord Callbacks & Observers, Season 2
ActiveRecord Callbacks & Observers, Season 2RORLAB
 
科学技術計算関連Pythonパッケージの概要
科学技術計算関連Pythonパッケージの概要科学技術計算関連Pythonパッケージの概要
科学技術計算関連Pythonパッケージの概要Toshihiro Kamishima
 
10のJava9で変わるJava8の嫌なとこ!
10のJava9で変わるJava8の嫌なとこ!10のJava9で変わるJava8の嫌なとこ!
10のJava9で変わるJava8の嫌なとこ!bitter_fox
 
Test strategies for data processing pipelines
Test strategies for data processing pipelinesTest strategies for data processing pipelines
Test strategies for data processing pipelinesLars Albertsson
 
出版・報告バイアスと研究発表への影響
出版・報告バイアスと研究発表への影響出版・報告バイアスと研究発表への影響
出版・報告バイアスと研究発表への影響英文校正エディテージ
 
Photon Technical Deep Dive: How to Think Vectorized
Photon Technical Deep Dive: How to Think VectorizedPhoton Technical Deep Dive: How to Think Vectorized
Photon Technical Deep Dive: How to Think VectorizedDatabricks
 
Building a Data Pipeline from Scratch - Joe Crobak
Building a Data Pipeline from Scratch - Joe CrobakBuilding a Data Pipeline from Scratch - Joe Crobak
Building a Data Pipeline from Scratch - Joe CrobakHakka Labs
 
A Journey into Databricks' Pipelines: Journey and Lessons Learned
A Journey into Databricks' Pipelines: Journey and Lessons LearnedA Journey into Databricks' Pipelines: Journey and Lessons Learned
A Journey into Databricks' Pipelines: Journey and Lessons LearnedDatabricks
 
CINF 13: Pistachio - Search and Faceting of Large Reaction Databases
CINF 13: Pistachio - Search and Faceting of Large Reaction DatabasesCINF 13: Pistachio - Search and Faceting of Large Reaction Databases
CINF 13: Pistachio - Search and Faceting of Large Reaction DatabasesNextMove Software
 
An Intro to Elasticsearch and Kibana
An Intro to Elasticsearch and KibanaAn Intro to Elasticsearch and Kibana
An Intro to Elasticsearch and KibanaObjectRocket
 
파이썬+함수이해하기 20160229
파이썬+함수이해하기 20160229파이썬+함수이해하기 20160229
파이썬+함수이해하기 20160229Yong Joon Moon
 
Beyond SQL: Speeding up Spark with DataFrames
Beyond SQL: Speeding up Spark with DataFramesBeyond SQL: Speeding up Spark with DataFrames
Beyond SQL: Speeding up Spark with DataFramesDatabricks
 
The Web Is Changing — From Strings to Things
The Web Is Changing — From Strings to ThingsThe Web Is Changing — From Strings to Things
The Web Is Changing — From Strings to ThingsMarkus Lanthaler
 
機械学習 / Deep Learning 大全 (2) Deep Learning 基礎編
機械学習 / Deep Learning 大全 (2) Deep Learning 基礎編機械学習 / Deep Learning 大全 (2) Deep Learning 基礎編
機械学習 / Deep Learning 大全 (2) Deep Learning 基礎編Daiyu Hatakeyama
 
Accelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks AutoloaderAccelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks AutoloaderDatabricks
 

Tendances (20)

Let's Build an Inverted Index: Introduction to Apache Lucene/Solr
Let's Build an Inverted Index: Introduction to Apache Lucene/SolrLet's Build an Inverted Index: Introduction to Apache Lucene/Solr
Let's Build an Inverted Index: Introduction to Apache Lucene/Solr
 
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
 
ActiveRecord Callbacks & Observers, Season 2
ActiveRecord Callbacks & Observers, Season 2ActiveRecord Callbacks & Observers, Season 2
ActiveRecord Callbacks & Observers, Season 2
 
科学技術計算関連Pythonパッケージの概要
科学技術計算関連Pythonパッケージの概要科学技術計算関連Pythonパッケージの概要
科学技術計算関連Pythonパッケージの概要
 
10のJava9で変わるJava8の嫌なとこ!
10のJava9で変わるJava8の嫌なとこ!10のJava9で変わるJava8の嫌なとこ!
10のJava9で変わるJava8の嫌なとこ!
 
Test strategies for data processing pipelines
Test strategies for data processing pipelinesTest strategies for data processing pipelines
Test strategies for data processing pipelines
 
出版・報告バイアスと研究発表への影響
出版・報告バイアスと研究発表への影響出版・報告バイアスと研究発表への影響
出版・報告バイアスと研究発表への影響
 
Photon Technical Deep Dive: How to Think Vectorized
Photon Technical Deep Dive: How to Think VectorizedPhoton Technical Deep Dive: How to Think Vectorized
Photon Technical Deep Dive: How to Think Vectorized
 
Building a Data Pipeline from Scratch - Joe Crobak
Building a Data Pipeline from Scratch - Joe CrobakBuilding a Data Pipeline from Scratch - Joe Crobak
Building a Data Pipeline from Scratch - Joe Crobak
 
knod22-Alani.pdf
knod22-Alani.pdfknod22-Alani.pdf
knod22-Alani.pdf
 
A Journey into Databricks' Pipelines: Journey and Lessons Learned
A Journey into Databricks' Pipelines: Journey and Lessons LearnedA Journey into Databricks' Pipelines: Journey and Lessons Learned
A Journey into Databricks' Pipelines: Journey and Lessons Learned
 
CINF 13: Pistachio - Search and Faceting of Large Reaction Databases
CINF 13: Pistachio - Search and Faceting of Large Reaction DatabasesCINF 13: Pistachio - Search and Faceting of Large Reaction Databases
CINF 13: Pistachio - Search and Faceting of Large Reaction Databases
 
¿Cual Es Tu Hijo Consentido?
¿Cual Es Tu Hijo Consentido?¿Cual Es Tu Hijo Consentido?
¿Cual Es Tu Hijo Consentido?
 
An Intro to Elasticsearch and Kibana
An Intro to Elasticsearch and KibanaAn Intro to Elasticsearch and Kibana
An Intro to Elasticsearch and Kibana
 
파이썬+함수이해하기 20160229
파이썬+함수이해하기 20160229파이썬+함수이해하기 20160229
파이썬+함수이해하기 20160229
 
Beyond SQL: Speeding up Spark with DataFrames
Beyond SQL: Speeding up Spark with DataFramesBeyond SQL: Speeding up Spark with DataFrames
Beyond SQL: Speeding up Spark with DataFrames
 
The Web Is Changing — From Strings to Things
The Web Is Changing — From Strings to ThingsThe Web Is Changing — From Strings to Things
The Web Is Changing — From Strings to Things
 
機械学習 / Deep Learning 大全 (2) Deep Learning 基礎編
機械学習 / Deep Learning 大全 (2) Deep Learning 基礎編機械学習 / Deep Learning 大全 (2) Deep Learning 基礎編
機械学習 / Deep Learning 大全 (2) Deep Learning 基礎編
 
Apache Spark Crash Course
Apache Spark Crash CourseApache Spark Crash Course
Apache Spark Crash Course
 
Accelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks AutoloaderAccelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks Autoloader
 

Similaire à Elastic search and Symfony3 - A practical approach

ElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersBen van Mol
 
Elasticsearch an overview
Elasticsearch   an overviewElasticsearch   an overview
Elasticsearch an overviewAmit Juneja
 
Eventually Elasticsearch: Eventual Consistency in the Real World
Eventually Elasticsearch: Eventual Consistency in the Real WorldEventually Elasticsearch: Eventual Consistency in the Real World
Eventually Elasticsearch: Eventual Consistency in the Real WorldBeyondTrees
 
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...Codemotion
 
ElasticSearch - index server used as a document database
ElasticSearch - index server used as a document databaseElasticSearch - index server used as a document database
ElasticSearch - index server used as a document databaseRobert Lujo
 
NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0
NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0
NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0Tugdual Grall
 
Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"George Stathis
 
Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...Maxime Beugnet
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to ElasticsearchSperasoft
 
曾勇 Elastic search-intro
曾勇 Elastic search-intro曾勇 Elastic search-intro
曾勇 Elastic search-introShaoning Pan
 
(BDT209) Launch: Amazon Elasticsearch For Real-Time Data Analytics
(BDT209) Launch: Amazon Elasticsearch For Real-Time Data Analytics(BDT209) Launch: Amazon Elasticsearch For Real-Time Data Analytics
(BDT209) Launch: Amazon Elasticsearch For Real-Time Data AnalyticsAmazon Web Services
 
Elasticsearch, a distributed search engine with real-time analytics
Elasticsearch, a distributed search engine with real-time analyticsElasticsearch, a distributed search engine with real-time analytics
Elasticsearch, a distributed search engine with real-time analyticsTiziano Fagni
 
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)Pat Patterson
 
Webinar: The Anatomy of the Cloudant Data Layer
Webinar: The Anatomy of the Cloudant Data LayerWebinar: The Anatomy of the Cloudant Data Layer
Webinar: The Anatomy of the Cloudant Data LayerIBM Cloud Data Services
 
Elastic search intro-@lamper
Elastic search intro-@lamperElastic search intro-@lamper
Elastic search intro-@lampermedcl
 
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital.AI
 
Introduction to MongoDB and Workshop
Introduction to MongoDB and WorkshopIntroduction to MongoDB and Workshop
Introduction to MongoDB and WorkshopAhmedabadJavaMeetup
 

Similaire à Elastic search and Symfony3 - A practical approach (20)

ElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersElasticSearch for .NET Developers
ElasticSearch for .NET Developers
 
Elasticsearch an overview
Elasticsearch   an overviewElasticsearch   an overview
Elasticsearch an overview
 
Eventually Elasticsearch: Eventual Consistency in the Real World
Eventually Elasticsearch: Eventual Consistency in the Real WorldEventually Elasticsearch: Eventual Consistency in the Real World
Eventually Elasticsearch: Eventual Consistency in the Real World
 
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...
 
ElasticSearch - index server used as a document database
ElasticSearch - index server used as a document databaseElasticSearch - index server used as a document database
ElasticSearch - index server used as a document database
 
NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0
NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0
NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0
 
Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to Elasticsearch
 
曾勇 Elastic search-intro
曾勇 Elastic search-intro曾勇 Elastic search-intro
曾勇 Elastic search-intro
 
ACM BPM and elasticsearch AMIS25
ACM BPM and elasticsearch AMIS25ACM BPM and elasticsearch AMIS25
ACM BPM and elasticsearch AMIS25
 
(BDT209) Launch: Amazon Elasticsearch For Real-Time Data Analytics
(BDT209) Launch: Amazon Elasticsearch For Real-Time Data Analytics(BDT209) Launch: Amazon Elasticsearch For Real-Time Data Analytics
(BDT209) Launch: Amazon Elasticsearch For Real-Time Data Analytics
 
Elasticsearch, a distributed search engine with real-time analytics
Elasticsearch, a distributed search engine with real-time analyticsElasticsearch, a distributed search engine with real-time analytics
Elasticsearch, a distributed search engine with real-time analytics
 
All about elasticsearch language clients
All about elasticsearch language clientsAll about elasticsearch language clients
All about elasticsearch language clients
 
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)
 
Webinar: The Anatomy of the Cloudant Data Layer
Webinar: The Anatomy of the Cloudant Data LayerWebinar: The Anatomy of the Cloudant Data Layer
Webinar: The Anatomy of the Cloudant Data Layer
 
Elastic search intro-@lamper
Elastic search intro-@lamperElastic search intro-@lamper
Elastic search intro-@lamper
 
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
 
Introduction to MongoDB and Workshop
Introduction to MongoDB and WorkshopIntroduction to MongoDB and Workshop
Introduction to MongoDB and Workshop
 

Dernier

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Dernier (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Elastic search and Symfony3 - A practical approach

  • 1. Nadhiir Rosun / @nads_rosun E l a s t i c s e a r c h a n d S y m f o n y 31/03/2017 A p r a c t i c a l a p p r o a c h
  • 2. 2 1. Introduction 2. ES versus RDBMS 3. Talking to ES 4. Architecture 5. Querying ES 6. Case study 7. Conclusions
  • 3. 3 Introduction Highly scalable open-source full-text search and analytics engine Allows you to store, search, and analyze big volumes of data quickly and in near real time. Build on top of Apache Lucene ¬ Popular/powerfull full-text search engine library Developed in Java
  • 4. 4 Introduction / Projects using ES Wikipedia ¬ Full-text search ¬ Highlighted search snippets ¬ Search-as-you-type ¬ Did-you-mean suggestions The Guardian ¬ Real–time analytics of visitor logs Stack Overflow ¬ Full-text search with geolocation queries ¬ Find related questions and answers GitHub ¬ Query 130 billion lines of code
  • 5. 5 Introduction / Use case 1 An online store Customers can search for products Big volume of products / large amount of transactions Product catalog to be full-text search, autocomplete suggestions, did-you-mean suggestions
  • 6. 6 Introduction / Use case 2 Analytics/business intelligence needs Collect log and transaction data  Analyze the data to look for trends, statistics & summarizations Build custom dashboard to visualize aspects of the data
  • 7. 7 1. Introduction 2. ES versus RDBMS 3. Talking to ES 4. Architecture 5. Querying ES 6. Case study 7. Conclusions
  • 8. 8 ES versus RDBMS Document oriented (NoSQL) Schema free Easily distributed & scalable All fields indexed Comprehensive and powerfull RESTful API Advanced search ¬ Full-text search ¬ Aggregations
  • 9. 9 ES versus RDBMS / Teminology Relational database ES Database Index Table Type Row Document SELECT GET INSERT PUT/POST UPDATE PUT/POST DELETE DELETE
  • 10. 10 1. Introduction 2. ES versus RDBMS 3. Talking to ES 4. Architecture 5. Querying ES 6. Case study 7. Conclusions
  • 11. 11 Talking to ES / Installation https://www.elastic.co/downloads/elasticsearch Check if ES is running ¬ http://localhost:9200/ { "name" : "Cp8oag6", "cluster_name" : "elasticsearch", "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA", "version" : { "number" : "5.3.0", "build_hash" : "f27399d", "build_date" : "2016-03-30T09:51:41.449Z", "build_snapshot" : false, "lucene_version" : "6.4.1" }, "tagline" : "You Know, for Search" }
  • 12. 12 Talking to ES RESTful API with JSON over HTTP ¬ Curl ¬ Guzzle ¬ Kibana PHP Client ¬ Official php client - https://github.com/elastic/elasticsearch-php ¬ Elastica - https://github.com/ruflin/Elastica Framework specific ¬ Symfony : FOSElasticaBundle - https://github.com/FriendsOfSymfony/FOSElasticaBundle ¬ Drupal 8 : Elasticsearch Connector - https://www.drupal.org/project/elasticsearch_connector
  • 13. 13 Talking to ES / Kibana
  • 14. 14 Talking to ES / Index a document PUT /[index]/[type]/[doc_id] Request PUT /providers/accomodation/1 { "name" : "Beaurivage Appartments", "about" : "Room or studio accommodation in the centre of the village", "city" : "Grand Baie", "star" : 3, "facility" : ["Internet", "Pool", “Television”, "Parking"] }
  • 15. 15 Talking to ES / Index a document Response { "_index": "providers", "_type": "accomodation", "_id": "1", "_version": 1, "result": "created", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "created": true }
  • 16. 16 Talking to ES / Retrieve a document GET /[index]/[type]/[doc_id] Request GET /providers/accomodation/1
  • 17. 17 Talking to ES / Retrieve a document Response { "_index": "providers", "_type": "accomodation", "_id": "1", "_version": 1, "found": true, "_source": { "name": "Beaurivage Appartments", "about": "Room or studio accommodation in the centre of the village", "city": "Grand Baie", "star": 3, "facility": ["Internet", "Pool", "Television", "Parking"] } }
  • 18. 18 Talking to ES / Update a document PUT /[index]/[type]/[doc_id] Request PUT /providers/accomodation/1 { "name" : "Beaurivage Appartments", "about" : "Room or studio accommodation in the centre of the village", "city" : "Grand Baie", "star" : 4, "facility" : ["Internet", "Pool", “Television”, "Parking"] }
  • 19. 19 Talking to ES / Update a document Response { "_index": "providers", "_type": "accomodation", "_id": "1", "_version": 2, "result": “updated", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "created": true }
  • 20. 20 Talking to ES / Delete a document DELETE /[index]/[type]/[doc_id] Request DELETE /providers/accomodation/1
  • 21. 21 Talking to ES / Delete a document Response { "found": true, "_index": "providers", "_type": "accomodation", "_id": "1", "_version": 3, "result": "deleted", "_shards": { "total": 2, "successful": 1, "failed": 0 } }
  • 22. 22 1. Introduction 2. ES versus RDBMS 3. Talking to ES 4. Architecture 5. Querying ES 6. Case study 7. Conclusions
  • 23. 23 Architecture / Cluster A collection of one or more nodes (servers) ¬ Sharing the same cluster name ¬ Working together to share data/workload Perfectly fine to have a cluster with only a single node
  • 24. 24 Architecture / Node A single server that is part of your cluster ¬ A single instance of ES Master node ¬ One node is elected as MASTER ¬ Manage cluster-wide changes
  • 25. 25 Architecture / Shard Think of shards as containers for data ¬ Allows to horizontally split/scale your content volume ¬ Allows to distribute and parallelize operations(Performance) Primary shard : ¬ Document is first indexed on a single primary shard Replica shard : ¬ Is just a copy of a primary shard ¬ Protect against hardware failure / share server load
  • 26. 26 Architecture / Index A collection of documents with similar characteristics ¬ An index for : - Customer data - Product catalog - Order data Create an index PUT /providers { "settings" : { "number_of_shards" : 3, "number_of_replicas" : 1 } }
  • 27. 27 Architecture / Type A logical category/partition of your index Within an index, you can define one or more types Has a list of fields mapping A type is defined for documents that have a set of common fields ¬ Product index with perishable type and non-perishable type √ ¬ Blog index with article type and log type ×
  • 28. 28 Architecture / Document A basic unit of information that can be indexed A JSON object stored in a single shard Uniquely identified by its index, type and id { "_index": "providers", "_type": "accomodation", "_id": "1", "_version": 1, "_source": { "name": "Beaurivage Appartments", "about": "Room or studio accommodation in the centre of the village", "city": "Grand Baie", "star": 3, "facility": ["Internet", "Pool", "Television", "Parking"] } }
  • 29. 29 Architecture / Mapping ES automatically creates a mapping/schema GET /[index]/_mapping/[type] GET /providers/_mapping/accomodation { "providers": { "mappings": { "accomodation": { "properties": { "about": { …, "type": "text", … }, "city": { …, "type": "text", … }, "facility": { …, "type": "keyword", … }, "name": { …, "type": "text", … }, "stars": { …, "type": "long“, … } } … }
  • 30. 30 1. Introduction 2. ES versus RDBMS 3. Talking to ES 4. Architecture 5. Querying ES 6. Case study 7. Conclusions
  • 31. 31 Querying ES / Query DSL JSON-style domain-specific language to execute queries GET /providers/accommodation/_search { "query": { "bool": { "must": [ { "match": { “name": " Appartments " }}, { "match": { “about": " Appartments " }} ], "filter": [ { "term": { " facility ": “Internet" }}, { "range": { “stars": { "gte": “3" }}} ] } } }
  • 32. 32 Querying ES / Query DSL Match all ¬ Simply matches all documents - SELECT * FROM providers.accommodation GET /providers/accommodation/_search { "query": { "match_all": {} } }
  • 33. 33 Querying ES / Query DSL Match ¬ Query a field - SELECT * FROM providers.accommodation p WHERE p.name = ‘Beaurivage’ GET /providers/accommodation/_search { "query": { "match": { “name” : “Beaurivage” } } }
  • 34. 34 Querying ES / Query DSL Range ¬ Find numbers or dates that fall into a specified range - SELECT * FROM providers.accommodation p WHERE p.stars > 3 GET /providers/accommodation/_search { "query": { "range" : { “stars" : { "gte" : 3, } } } }
  • 35. 35 Querying ES / Query DSL Term ¬ Finds documents that contain the exact term - SELECT * FROM providers.accommodation p WHERE p.facilities = ‘Internet’ GET /providers/accommodation/_search { "query": { "term" : { “facility" : “Internet" } } }
  • 36. 36 Querying ES / Query DSL Bool ¬ Combine query clauses - Must : › The clause must appear in matching documents › Contribute to score - Filter : › The clause must appear in matching documents › Scoring is ignored GET /providers/accommodation/_search { "query": { "bool": { "must": [ … ], "filter": [ … ] } } }
  • 37. 37 Querying ES / Query DSL Pagination ¬ From - Similar to offset in sql ¬ Size - Similar to limit in sql ¬ SELECT * FROM providers.accommodation p LIMIT 10 OFFSET 15 GET /providers/accommodation/_search { "query": { “match_all” : {} }, “from” : 15, “size” : 10 }
  • 38. 38 Querying ES / Full-text search Structured search ¬ Something either belongs in the set or it does not ¬ Simply includes or excludes documents ¬ Does not worry about document relevance or scoring ¬ Very fast and cachable Full-text search ¬ Finds how well a documents match the search keywords ¬ Analysis/Inverted index ¬ Each document gets a score ¬ Return documents sorted by relevance
  • 39. 39 Querying ES / Full-text search Case study : 2 documents { "name" : "Beaurivage Appartments", "about" : "Room or studio accommodation in the centre of the village", "city" : "Grand Baie", "star" : 3, "facility" : ["Internet", "Pool", “Television”, "Parking"] }, { "name" : "Hotel Allamanda", "about" : "Hotel room in front of the best lagoon of the island.", "city" : "Tamarin", "star" : 5, "facility" : ["Internet", “Beach", “Telephone”, "Parking"] },
  • 40. 40 Querying ES / Full-text search Case study : Full-text search query GET /providers/accomodation/_search { "query": { "match": { "about": "Room accomodation" } } }
  • 41. 41 Querying ES / Full-text search Response { "took": 218, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 2, "max_score": 0.28488502, "hits": [ { "_index": "providers", "_type": "accomodation", "_id": "1", "_score": 0.28488502, "_source": { … } }, { "_index": "providers", "_type": "accomodation", "_id": "2", "_score": 0.24257512, "_source": { … } } } }
  • 42. 42 Querying ES / Query DSL Inverted Index ¬ Designed to allow very fast full-text searches ¬ Consists of : - a list of all the unique words that appear in any document - For each word, a list of the documents in which it appears. 1.The quick brown fox jumped over the lazy dog 1.Quick brown foxes leap over lazy dogs in summer
  • 43. 43 Querying ES / Query DSL Split into separate tokens List of unique tokens List in which document each term appears Notice: - Quick and quick appear as separate terms - fox and foxes share the same root word
  • 44. 44 Querying ES / Query DSL Analyzers ¬ Character Filters - Tidy up string - Strip out HTML and ‘&’ ¬ Tokenizer - Split into tokens/terms - Every whitespace/punctuation ¬ Token Filters - Can change the tokens › Lowercase › Add synonyms › Remove stopwords (a, and, the…) Token Filters Tokenizer Character filters
  • 45. 45 1. Introduction 2. ES versus RDBMS 3. Talking to ES 4. Architecture 5. Querying ES 6. Case study 7. Conclusions
  • 46. 46 Case study / SF3 resto search engine Creating a simple restaurant search engine ¬ Full-text search ¬ Facets ¬ Pagination Techno : ¬ Symfony 3 - FOSElasticaBundle - PagerBundle ¬ Elasticsearch
  • 47. 47 Case study / SF3 resto search engine
  • 48. 48 Case study / SF3 resto search engine MySQLES Restaurant - Name - About - City - facilities Restaurant - Name - About - City - photo - facilities App 1. New/Update/Delete Serializer 2. Doctrine object 3. JSON object Indexing
  • 49. 49 Case study / SF3 resto search engine MySQLES Restaurant - Name - About - City - facilities Restaurant - Name - About - City - photo - facilities App Finder 5.Doctrine object 2. JSON object 1. Search 3,4. Fetch from db Searching
  • 50. 50 Case study / SF3 resto search engine Installing the bundles with composer your_project/composer.json "require": { … “friendsofsymfony/elastica-bundle": "^3.0", "ruflin/elastica": "3.1.1 as 2.99.0", "white-october/pagerfanta-bundle": "dev-master", }
  • 51. 51 Case study / SF3 resto search engine Register the bundles your_project/app/AppKernel.php $bundles = [ … new FOSElasticaBundleFOSElasticaBundle(), new WhiteOctoberPagerfantaBundleWhiteOctoberPagerfantaBundle(), ];
  • 52. 52 Case study / SF3 resto search engine Configuration ¬ Add ES server address in ‘parameters.yml’ your_project/app/config/parameters.yml parameters: … elastica_host: localhost elastica_port: 9200 ¬ Create/import new configuration file ‘fos_elastica.yml’ your_project/app/config/config.yml imports: … - { resource: fos_elastica.yml }
  • 53. 53 Case study / SF3 resto search engine your_project/app/config/fos_elastica.yml fos_elastica: clients: default: { host: "%elastica_host%", port: "%elastica_port%" } indexes: prov: client: default types: restaurant: mappings: name: ~ about: ~ city: ~ facilities: type: keyword persistence: driver: orm model: AppBundleEntityRestaurant finder: ~ provider: ~ listener: ~
  • 54. 54 Case study / SF3 resto search engine Persistence ¬ Defines how FOSElasticaBundle will index your docs depending on your symfony entities Driver ¬ Driver to use (ORM) Model ¬ Allow to define an ES doc from a symfony entity Finder ¬ Search interface (deserialize JSON objects into doctrine objects) Provider ¬ Indexing interface (serialize doctrine objects to JSON objects) Listener ¬ List of listeners for which the indexing is called - Default : insert, update & delete
  • 55. 55 Case study / SF3 resto search engine File structure
  • 56. 56 Case study / SF3 resto search engine Create Entity ‘Restaurant’ your_project/src/AppBundle/Entity/Restaurant.php class Restaurant { protected $id; protected $name; protected $about; protected $city; protected $photo; protected $facilities; //getters and setters }
  • 57. 57 Case study / SF3 resto search engine Index the doctrine objects to ES ¬ Uses the provider defined in fos_elastica.yml ¬ Serialize Doctrine objects to JSON using the Symfony Serializer component - Uses the predefined mapping in this process From the command line php bin/console fos:elastica:populate
  • 58. 58 Case study / SF3 resto search engine Create the form model ¬ Mapped to the FormType ¬ Contain two properties - title - facilities your_project/src/AppBundle/Model/SearchModel.php class SearchModel { protected $title; //string protected $facilities; //array //getters and setters }
  • 59. 59 Case study / SF3 resto search engine Create the form type ¬ Contain two fields : title, facilities your_project/src/AppBundle/Form/Type/SearchType.php $builder ->add('title', null, array( 'required' => false, )) ->add('facilities', ChoiceType::class, array( 'choices' => array( 'Internet' => 'Internet', 'Parking' => 'Parking', 'Toilet' => 'Toilet', 'Beach' => 'Beach', 'Card Payment' => 'Card Payment', ), 'expanded' => true, 'multiple' => true, )) ->add('search', SubmitType::class);
  • 60. 60 Case study / SF3 resto search engine Bundle everything in your search action your_project/src/AppBundle/Controller/DefaultController.php $perPage = 8; // Create form $searchModel = new SearchModel(); $searchForm = $this->createForm(SearchType::class, $searchModel); // Get form data $searchForm->handleRequest($request); $searchModel = $searchForm->getData(); // Perform query in ES $elasticaManager = $this->container->get('fos_elastica.manager'); $results = $elasticaManager->getRepository('AppBundle:Restaurant')->search($searchModel); // Pagination $adapter = new ArrayAdapter($results); $pager = new Pagerfanta($adapter); $pager->setMaxPerPage($perPage); $pager->setCurrentPage($page); // return results, pager and form to your template
  • 61. 61 Case study / SF3 resto search engine ES search repository your_project/src/AppBundle/Repository/SearchRepository.php $boolQuery = new ElasticaQueryBoolQuery(); // Search Field name $queryName = new ElasticaQueryMatch(); $queryName->setFieldQuery('name', $searchModel->getTitle()); $boolQuery->addShould($queryName); // Search Field about $queryAbout = new ElasticaQueryMatch(); $queryAbout->setFieldQuery('about', $searchModel->getTitle()); $queryAbout->setFieldParam('about', 'analyzer', 'english'); $boolQuery->addShould($queryAbout); … // Terms if (count($searchModel->getFacilities()) > 0) { $tagsQuery = new ElasticaQueryTerms(); $tagsQuery->setTerms('facilities', $searchModel->getFacilities()); $boolQuery->addMust($tagsQuery); } $query = ElasticaQuery::create($boolQuery);
  • 62. 62 1. Introduction 2. ES versus RDBMS 3. Talking to ES 4. Architecture 5. Querying ES 6. Case study 7. Conclusions
  • 64. extension interactive 14, avenue des Lataniers 72238 Quatre Bornes Thank you 