Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Elasticsearch i Symfony, FosElasticaBundle

Elasticsearch i Symfony, FosElasticaBundle

DaFED#32
Speaker: Miloš Milojević
Elasticsearch je search server baziran na Lucene-u, napisan u Javi, i objavljen kao open source projekat. Tokom predavanja, upoznaćemo se sa terminima Symfony i Elasticsearch, kao i kako integrisati Elasticsearch engine na konkretnom Symfony projektu uz par praktičnih saveta.

DaFED

May 06, 2015
Tweet

More Decks by DaFED

Other Decks in Programming

Transcript

  1. Miloš Milojević Master’s Degree in Communication and Information Technology. Web

    developer in Eton Digital. Loves open source. Interested in database architecture and optimisation.
  2. curl -XGET ‘http://localhost:9200’ { "status" : 200, "name" : "Tutinax

    the Mountain-Mover", "cluster_name" : "elasticsearch", "version" : { "number" : "1.5.2", "build_hash" : "62ff9868b4c8a0c45860bebb259e21980778ab1c", "build_timestamp" : "2015-04-27T09:21:06Z", "build_snapshot" : false, "lucene_version" : "4.10.4" }, "tagline" : "You Know, for Search" }
  3. -Cluster cluster.name = elasticsearch -Nodes: -Allow this node to be

    eligible as a master node (enabled by default): #node.master: true -Allow this node to store data (enabled by default): #node.data: true
  4. You can exploit these settings to design advanced cluster topologies.

    Node example: 1. You want this node to never become a master node, only to hold data. This will be the "workhorse" of your cluster. node.master: false node.data: true
  5. Node example: 2. You want this node to only serve

    as a master: to not store any data and to have free resources. This will be the "coordinator" of your cluster. node.master: true node.data: false
  6. Node example: 3. You want this node to be neither

    master nor data node, but to act as a "search load balancer" (fetching data from nodes,aggregating results, etc.) node.master: false node.data: false
  7. { “ok” : true, “_index” : “milos”, “_type” : “post”,

    “_id” : “1”, “_version” : 1 } milos milos_sec milos
  8. { “ok” : true, “_index” : “milos”, “_type” : “post”,

    “_id” : “1”, “_version” : 1 } milos post user
  9. { “ok” : true, “_index” : “milos”, “_type” : “post”,

    “_id” : “1”, “_version” : 1 } milos post 1 2 3
  10. Add document: curl -XPUT “http:localhost:9200/milos/post/1” -d “{‘title’ : ‘Introduction to

    elasticsearch’}” {"_index":"milos","_type":"post","_id":"1","_version":1,"created":true} Index type id
  11. Update: curl -XPOST “http:localhost:9200/milos/post/1” -d “{ ‘title’ : ‘Introduction to

    elasticsearch’, ‘tags’ : [‘elasticsearch’,‘php’] }” {"_index":"milos","_type":"post","_id":"1","_version":2,"created":false}
  12. "hits": { "total":1, "max_score":0.13424811, "hits": [{ "_index":"milos", "_type":"post", "_id":"1", "_score":0.13424811,

    "_source": { "title" : "Introduction to elasticsearch", "tags": ["elasticsearch", "php"] } }] } }
  13. { "_index":"milos", "_type":"post", "_id":"1", "_score":0.2712221, "_source": { "title" : "Introduction

    to elasticsearch", "tags": ["elasticsearch", "php"] } }, { "_index":"milos", "_type":"post", "_id":"2", "_score":0.2712221, "_source": { "title" : "Introduction to elasticsearch number 2", "tags": ["elasticsearch", "php"] } }
  14. curl -XPUT “http://localhost:9200/milos” -d ‘ { “settings” : { “number_of_shards”

    : 10, “number_of_replicas” : 3 }, { “mappings” : { “document” : { “properties” : {“title” : { “type” : string, “analyzer” : “lowercase” }} }}’
  15. MySql Elasticsearch Database Index Table Type Row Document Column Field

    Schema Mapping Index Everything is indexed Sql Query DSL Select * from table…. GET http://…. Update table SET ... POST http://…. Terminology