SlideShare a Scribd company logo
Laravel and ElasticSearch
Getting started building a powerful search engine
Peter Steenbergen
Who am I?
What I am about to cover
• Benefits of ElasticSearch
• ElasticSearch Basics
• Examples of Searchengines
• Installing the tools
• Analyzing and feeding the data
• Searching with Laravel and ElasticSearch through VueJS
What I do NOT cover
• Type of queries
• Analyzers
• Filters
• Percolator
• Internals of Elasticsearch (Lucene Index)
• Talk of Elze Kool - GroningenPHP
https://bitbucket.org/elzekool/talk-solr-elasticsearch-internals/src
The internals will cover how a score is determined in the background.
Benefits of ElasticSearch
What is a “powerful search”?
• Fast
Search in milliseconds, not in seconds.
• Relevant
If you search for a Hotel in California, don’t return Hotels in
Groningen. Or a black Audi, you don’t want to see a white Peugeot
107.
• Scalable
If your data grows, then you need more resources. It could mean by
vertical scaling or (better) horizontal scaling of capacity.
MySQL Drawbacks for searching through text
• LIKE %%
• Fast? No, try searching for millions of records with multiple joins to combine
all the information needed.
• Relevant? No, Try search for “PHP programmeur” or “PHP developer”, or
“Audi A8 zwart” or “zwarte Audi A8“.
• Scalable? Could be, but with much hassle in configurations in production and
backing up.
• Facets / Counts – How many Audi’s? How many black cars? Takes
multiple query’s for the calculation of those counts.
NB: FULL TEXT not noted here, gave a bit better result but not great.
ElasticSearch Basics
The Elastic Stack – formerly known as ELK stack
Usage of the Elastic stack
• Time-series data
Log files, searched queries, view count of document
• Insights in your data
• Machine-Learning capabilities
• Reversal of search queries with percolator (storing search queries)
• Zero-downtime* index swapping
Last 7 days, Last 30 days, or products => products-20180327
Components of ElasticSearch
• Node
Instance of ElasticSearch.
• Cluster
One or more nodes that work together to serve the same data and
API requests.
• Document
A piece of stored data you want to search for. (MySQL Row)
• Index
A collection of documents that have somewhat similar characteristics.
(MySQL Table)
Getting started with Laravel & Elasticsearch
Getting started with Laravel & Elasticsearch
CRUD operations
Searchengine Examples
Getting started with Laravel & Elasticsearch
Getting started with Laravel & Elasticsearch
Getting started with Laravel & Elasticsearch
Getting started with Laravel & Elasticsearch
Lets build that coolblue page!
First up: installation of the following tools
• MySQL (ElasticSearch does not support transactions!)
• ElasticSearch
• Laravel
• VueJS / VueX
Setting up / Starting MySQL on OSX
• Default credentials
User: root
Password: <empty>
Port: 3301
> Now create a Database called “coolshop”
Installing laravel
• We use composer for the installation
• If you don’t have it, get it from here: https://getcomposer.org
Run the following in your terminal: Laravel Installer:
Setting up / Starting ElasticSearch on OSX
Settings / name, cluster_name:
/usr/local/etc/elasticsearch/elasticsearch.yml
Java Virtual Machine options:
/usr/local/etc/elasticsearch/jvm.options
-Xms2g => -Xms256m
-Xmx2g => -Xmx256m
Maximum of 32GB per node is recommended
NB: 256m is for small dev boxes and not production!!
Installing additional packages
• ElasticSearch composer package
• Guzzle (optional)
• VueX for using Store
• Setup default FrontEnd scaffold
Creating the Service Provider and Config
• config/elasticsearch.php
Setting the ElasticSearch ServiceProvider
Register the ElasticSearch ServiceProvider
NB: config/app.php
Commands
• app/Console/Kernel.php
Testing the setup – we go Ping-Pong
Analyzing and Feeding the data
Analyzing the data
• Image
• AwardImage
• Title
• Rating
• ReviewCount
• ProductOptions
• Price
• PriceSecondChange
• InStock
• TypeRouter
• Brand
• CoolbluesChoice
• AdministratorOptions
Mapping the data
Analyzing the data
• Image => Keyword
• AwardImage => Keyword
• Title => Text
• Rating => Float
• ReviewCount => Integer
• ProductOptions => Text
• Price => Float
• PriceSecondChange => Float
• InStock => Boolean
• TypeRouter => Keyword
• Brand => Keyword
• CoolbluesChoice => Keyword
• AdministratorOptions => Keyword
Put the mapping in ElasticSearch
Kibana is a no-brainer for this. It has an own
Dev Console.
Or with the PHP Client of ElasticSearch.
Lets inject some data in the Elasticsearch
Front-End integration
Getting started with Laravel & Elasticsearch
Getting started with Laravel & Elasticsearch
Getting started with Laravel & Elasticsearch
Getting started with Laravel & Elasticsearch
Getting started with Laravel & Elasticsearch
Getting started with Laravel & Elasticsearch
Compile the front-end
In the console run:
• Development
npm run dev one-time build
npm run watch listener for changes
• Production
npm run production
Connecting the dots
Adding the endpoint – api.php
Getting started with Laravel & Elasticsearch
Aggregations
Transform the result
The end result
Getting started with Laravel & Elasticsearch
Questions?
Twitter / Github: @petericebear
Email: psteenbergen@gmail.com
Blog: http://petericebear.github.io/
COUPONCODE: ELASTICMEETING
50% OFF - FIRST MONTH – Hosting
sales@virtio.nl

More Related Content

What's hot (20)

ODP
Deep Dive Into Elasticsearch
Knoldus Inc.
 
PDF
Kubernetes Docker Container Implementation Ppt PowerPoint Presentation Slide ...
SlideTeam
 
PDF
Docker swarm
Alberto Guimarães Viana
 
PDF
Kubernetes extensibility: CRDs & Operators
SIGHUP
 
PDF
Implementing Microservices with NATS
Apcera
 
PDF
Velero & Beyond: Backup & Restore for Kubernetes Applications (Cloud Native S...
Chakradhar Rao Jonagam
 
PDF
Open Service Broker APIとKubernetes Service Catalog #k8sjp
Toshiaki Maki
 
PDF
Presto anatomy
Dongmin Yu
 
PPTX
Kubernetes Cluster vs Nodes vs Pods vs Containers Comparison
jeetendra mandal
 
PPTX
Intro to Helm for Kubernetes
Carlos E. Salazar
 
PDF
Preparing for a future Microservices journey using DDD & Wardley Maps
Susanne Kaiser
 
PDF
The Patterns of Distributed Logging and Containers
SATOSHI TAGOMORI
 
PDF
helm 입문
choi sungwook
 
PDF
ProxySQL on Kubernetes
René Cannaò
 
PDF
Spark (Structured) Streaming vs. Kafka Streams
Guido Schmutz
 
PDF
BigQuery for Beginners
Better&Stronger
 
PDF
Terraform introduction
Jason Vance
 
PDF
Apache Iceberg: An Architectural Look Under the Covers
ScyllaDB
 
PPTX
Kubernetes Helm: Why It Matters
Platform9
 
PDF
Introducing DataFrames in Spark for Large Scale Data Science
Databricks
 
Deep Dive Into Elasticsearch
Knoldus Inc.
 
Kubernetes Docker Container Implementation Ppt PowerPoint Presentation Slide ...
SlideTeam
 
Kubernetes extensibility: CRDs & Operators
SIGHUP
 
Implementing Microservices with NATS
Apcera
 
Velero & Beyond: Backup & Restore for Kubernetes Applications (Cloud Native S...
Chakradhar Rao Jonagam
 
Open Service Broker APIとKubernetes Service Catalog #k8sjp
Toshiaki Maki
 
Presto anatomy
Dongmin Yu
 
Kubernetes Cluster vs Nodes vs Pods vs Containers Comparison
jeetendra mandal
 
Intro to Helm for Kubernetes
Carlos E. Salazar
 
Preparing for a future Microservices journey using DDD & Wardley Maps
Susanne Kaiser
 
The Patterns of Distributed Logging and Containers
SATOSHI TAGOMORI
 
helm 입문
choi sungwook
 
ProxySQL on Kubernetes
René Cannaò
 
Spark (Structured) Streaming vs. Kafka Streams
Guido Schmutz
 
BigQuery for Beginners
Better&Stronger
 
Terraform introduction
Jason Vance
 
Apache Iceberg: An Architectural Look Under the Covers
ScyllaDB
 
Kubernetes Helm: Why It Matters
Platform9
 
Introducing DataFrames in Spark for Large Scale Data Science
Databricks
 

Similar to Getting started with Laravel & Elasticsearch (20)

PDF
ElasticSearch & Elastica in Symfony2 - SfLive 2015
Nicolas Badey
 
PDF
Elasticsearch Introduction at BigData meetup
Eric Rodriguez (Hiring in Lex)
 
PPTX
An Introduction to Elastic Search.
Jurriaan Persyn
 
PDF
Elasticsearch : petit déjeuner du 13 mars 2014
ALTER WAY
 
PPTX
Perl and Elasticsearch
Dean Hamstead
 
ODP
Elastic search
Rahul Agarwal
 
PPTX
Elastic pivorak
Pivorak MeetUp
 
PPTX
Elasticsearch workshop presentation
Laura Steggles
 
PPTX
ElasticSearch Meetup 30 - 10 - 2014
Alberto Paro
 
PPTX
Dev nexus 2017
Roy Russo
 
PPT
Elk presentation1#3
uzzal basak
 
PDF
Real-time search in Drupal. Meet Elasticsearch
Alexei Gorobets
 
PDF
Getting Started with Elasticsearch
Alibaba Cloud
 
PPSX
Elasticsearch - basics and beyond
Ernesto Reig
 
PDF
Elasticsearch and Spark
Audible, Inc.
 
PPTX
Introduction to Elasticsearch
Ismaeel Enjreny
 
PDF
ElasticSearch Introduction
Minh Hoang
 
PDF
Modernizing WordPress Search with Elasticsearch
Taylor Lovett
 
PDF
Introduction to Elasticsearch
Ruslan Zavacky
 
PDF
Elasticsearch
Hermeto Romano
 
ElasticSearch & Elastica in Symfony2 - SfLive 2015
Nicolas Badey
 
Elasticsearch Introduction at BigData meetup
Eric Rodriguez (Hiring in Lex)
 
An Introduction to Elastic Search.
Jurriaan Persyn
 
Elasticsearch : petit déjeuner du 13 mars 2014
ALTER WAY
 
Perl and Elasticsearch
Dean Hamstead
 
Elastic search
Rahul Agarwal
 
Elastic pivorak
Pivorak MeetUp
 
Elasticsearch workshop presentation
Laura Steggles
 
ElasticSearch Meetup 30 - 10 - 2014
Alberto Paro
 
Dev nexus 2017
Roy Russo
 
Elk presentation1#3
uzzal basak
 
Real-time search in Drupal. Meet Elasticsearch
Alexei Gorobets
 
Getting Started with Elasticsearch
Alibaba Cloud
 
Elasticsearch - basics and beyond
Ernesto Reig
 
Elasticsearch and Spark
Audible, Inc.
 
Introduction to Elasticsearch
Ismaeel Enjreny
 
ElasticSearch Introduction
Minh Hoang
 
Modernizing WordPress Search with Elasticsearch
Taylor Lovett
 
Introduction to Elasticsearch
Ruslan Zavacky
 
Elasticsearch
Hermeto Romano
 
Ad

Recently uploaded (20)

PPTX
法国巴黎第二大学本科毕业证{Paris 2学费发票Paris 2成绩单}办理方法
Taqyea
 
PPTX
Presentation3gsgsgsgsdfgadgsfgfgsfgagsfgsfgzfdgsdgs.pptx
SUB03
 
PDF
AI_MOD_1.pdf artificial intelligence notes
shreyarrce
 
PPT
Agilent Optoelectronic Solutions for Mobile Application
andreashenniger2
 
PPTX
Lec15_Mutability Immutability-converted.pptx
khanjahanzaib1
 
PPTX
英国假毕业证诺森比亚大学成绩单GPA修改UNN学生卡网上可查学历成绩单
Taqyea
 
PPT
introductio to computers by arthur janry
RamananMuthukrishnan
 
PPTX
Optimization_Techniques_ML_Presentation.pptx
farispalayi
 
PPTX
ONLINE BIRTH CERTIFICATE APPLICATION SYSYTEM PPT.pptx
ShyamasreeDutta
 
PPTX
04 Output 1 Instruments & Tools (3).pptx
GEDYIONGebre
 
PPTX
原版西班牙莱昂大学毕业证(León毕业证书)如何办理
Taqyea
 
PDF
𝐁𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓
hokimamad0
 
PDF
Azure_DevOps introduction for CI/CD and Agile
henrymails
 
PPTX
L1A Season 1 Guide made by A hegy Eng Grammar fixed
toszolder91
 
PPTX
一比一原版(LaTech毕业证)路易斯安那理工大学毕业证如何办理
Taqyea
 
PDF
The-Hidden-Dangers-of-Skipping-Penetration-Testing.pdf.pdf
naksh4thra
 
PPTX
L1A Season 1 ENGLISH made by A hegy fixed
toszolder91
 
DOCX
Custom vs. Off-the-Shelf Banking Software
KristenCarter35
 
PPTX
PM200.pptxghjgfhjghjghjghjghjghjghjghjghjghj
breadpaan921
 
PDF
Build Fast, Scale Faster: Milvus vs. Zilliz Cloud for Production-Ready AI
Zilliz
 
法国巴黎第二大学本科毕业证{Paris 2学费发票Paris 2成绩单}办理方法
Taqyea
 
Presentation3gsgsgsgsdfgadgsfgfgsfgagsfgsfgzfdgsdgs.pptx
SUB03
 
AI_MOD_1.pdf artificial intelligence notes
shreyarrce
 
Agilent Optoelectronic Solutions for Mobile Application
andreashenniger2
 
Lec15_Mutability Immutability-converted.pptx
khanjahanzaib1
 
英国假毕业证诺森比亚大学成绩单GPA修改UNN学生卡网上可查学历成绩单
Taqyea
 
introductio to computers by arthur janry
RamananMuthukrishnan
 
Optimization_Techniques_ML_Presentation.pptx
farispalayi
 
ONLINE BIRTH CERTIFICATE APPLICATION SYSYTEM PPT.pptx
ShyamasreeDutta
 
04 Output 1 Instruments & Tools (3).pptx
GEDYIONGebre
 
原版西班牙莱昂大学毕业证(León毕业证书)如何办理
Taqyea
 
𝐁𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓
hokimamad0
 
Azure_DevOps introduction for CI/CD and Agile
henrymails
 
L1A Season 1 Guide made by A hegy Eng Grammar fixed
toszolder91
 
一比一原版(LaTech毕业证)路易斯安那理工大学毕业证如何办理
Taqyea
 
The-Hidden-Dangers-of-Skipping-Penetration-Testing.pdf.pdf
naksh4thra
 
L1A Season 1 ENGLISH made by A hegy fixed
toszolder91
 
Custom vs. Off-the-Shelf Banking Software
KristenCarter35
 
PM200.pptxghjgfhjghjghjghjghjghjghjghjghjghj
breadpaan921
 
Build Fast, Scale Faster: Milvus vs. Zilliz Cloud for Production-Ready AI
Zilliz
 
Ad

Getting started with Laravel & Elasticsearch

  • 1. Laravel and ElasticSearch Getting started building a powerful search engine Peter Steenbergen
  • 3. What I am about to cover • Benefits of ElasticSearch • ElasticSearch Basics • Examples of Searchengines • Installing the tools • Analyzing and feeding the data • Searching with Laravel and ElasticSearch through VueJS
  • 4. What I do NOT cover • Type of queries • Analyzers • Filters • Percolator • Internals of Elasticsearch (Lucene Index) • Talk of Elze Kool - GroningenPHP https://bitbucket.org/elzekool/talk-solr-elasticsearch-internals/src The internals will cover how a score is determined in the background.
  • 6. What is a “powerful search”? • Fast Search in milliseconds, not in seconds. • Relevant If you search for a Hotel in California, don’t return Hotels in Groningen. Or a black Audi, you don’t want to see a white Peugeot 107. • Scalable If your data grows, then you need more resources. It could mean by vertical scaling or (better) horizontal scaling of capacity.
  • 7. MySQL Drawbacks for searching through text • LIKE %% • Fast? No, try searching for millions of records with multiple joins to combine all the information needed. • Relevant? No, Try search for “PHP programmeur” or “PHP developer”, or “Audi A8 zwart” or “zwarte Audi A8“. • Scalable? Could be, but with much hassle in configurations in production and backing up. • Facets / Counts – How many Audi’s? How many black cars? Takes multiple query’s for the calculation of those counts. NB: FULL TEXT not noted here, gave a bit better result but not great.
  • 9. The Elastic Stack – formerly known as ELK stack
  • 10. Usage of the Elastic stack • Time-series data Log files, searched queries, view count of document • Insights in your data • Machine-Learning capabilities • Reversal of search queries with percolator (storing search queries) • Zero-downtime* index swapping Last 7 days, Last 30 days, or products => products-20180327
  • 11. Components of ElasticSearch • Node Instance of ElasticSearch. • Cluster One or more nodes that work together to serve the same data and API requests. • Document A piece of stored data you want to search for. (MySQL Row) • Index A collection of documents that have somewhat similar characteristics. (MySQL Table)
  • 20. Lets build that coolblue page!
  • 21. First up: installation of the following tools • MySQL (ElasticSearch does not support transactions!) • ElasticSearch • Laravel • VueJS / VueX
  • 22. Setting up / Starting MySQL on OSX • Default credentials User: root Password: <empty> Port: 3301 > Now create a Database called “coolshop”
  • 23. Installing laravel • We use composer for the installation • If you don’t have it, get it from here: https://getcomposer.org Run the following in your terminal: Laravel Installer:
  • 24. Setting up / Starting ElasticSearch on OSX Settings / name, cluster_name: /usr/local/etc/elasticsearch/elasticsearch.yml Java Virtual Machine options: /usr/local/etc/elasticsearch/jvm.options -Xms2g => -Xms256m -Xmx2g => -Xmx256m Maximum of 32GB per node is recommended NB: 256m is for small dev boxes and not production!!
  • 25. Installing additional packages • ElasticSearch composer package • Guzzle (optional) • VueX for using Store • Setup default FrontEnd scaffold
  • 26. Creating the Service Provider and Config • config/elasticsearch.php
  • 27. Setting the ElasticSearch ServiceProvider
  • 28. Register the ElasticSearch ServiceProvider NB: config/app.php
  • 30. Testing the setup – we go Ping-Pong
  • 32. Analyzing the data • Image • AwardImage • Title • Rating • ReviewCount • ProductOptions • Price • PriceSecondChange • InStock • TypeRouter • Brand • CoolbluesChoice • AdministratorOptions
  • 34. Analyzing the data • Image => Keyword • AwardImage => Keyword • Title => Text • Rating => Float • ReviewCount => Integer • ProductOptions => Text • Price => Float • PriceSecondChange => Float • InStock => Boolean • TypeRouter => Keyword • Brand => Keyword • CoolbluesChoice => Keyword • AdministratorOptions => Keyword
  • 35. Put the mapping in ElasticSearch Kibana is a no-brainer for this. It has an own Dev Console. Or with the PHP Client of ElasticSearch.
  • 36. Lets inject some data in the Elasticsearch
  • 44. Compile the front-end In the console run: • Development npm run dev one-time build npm run watch listener for changes • Production npm run production
  • 46. Adding the endpoint – api.php
  • 52. Questions? Twitter / Github: @petericebear Email: [email protected] Blog: http://petericebear.github.io/ COUPONCODE: ELASTICMEETING 50% OFF - FIRST MONTH – Hosting [email protected]

Editor's Notes

  • #4: Inleiding - Wat ga ik behandelen in deze presentatie. Globale overview..
  • #5: Inleiding - Wat ga ik behandelen in deze presentatie. Globale overview..
  • #11: Inleiding - Wat ga ik behandelen in deze presentatie. Globale overview..
  • #12: Inleiding - Wat ga ik behandelen in deze presentatie. Globale overview..
  • #15: Inleiding - Wat ga ik behandelen in deze presentatie. Globale overview..