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

Elastic Search

KMKLabs
March 22, 2016

Elastic Search

Elasticsearch merupakan sebuah infrastruktur TI untuk melakukan information retrieval. Untuk melakukan instalasi Elasticsearch kita harus menginstall Java Runtime Environment (JRE) terlebih dahulu, karena Elasticsearch membutuhkan Java Virtual Machine. JRE yang digunakan bisa dari Oracle atau OpenJDK.

KMKLabs

March 22, 2016
Tweet

More Decks by KMKLabs

Other Decks in Technology

Transcript

  1. Instalasi 0. Install JAVA 1. Download .tar.gz https://www.elastic.co/downloads/elasticsearch 2. Repositories

    https://www.elastic.co/guide/en/elasticsearch/refere nce/current/setup-repositories.html
  2. Konfigurasi /etc/elasticsearch/: elasticsearch.yml — Configures the Elasticsearch server settings. This

    is where all options, except those for logging, are stored, which is why we are mostly interested in this file. logging.yml — Provides configuration for logging. In the beginning, you don't have to edit this file. You can leave all default logging options. You can find the resulting logs in /var/log/elasticsearch by default.
  3. # node # cluster # shard (index.number_of_shards: 5) indexing >>

    #replica (index.number_of_replicas: 5) searching >>
  4. # node.master true / false # node.data true / false

    # path.data default: /var/lib/elasticsearch nfs: /media/different_media * type category / partition * document json
  5. Start elasticsearch server $ sudo service elasticsearch start $ sudo

    /bin/systemctl start elasticsearch.service $ bin/elasticsearch
  6. Index & Query Document curl -XPUT 'localhost:9200/customer/external/1?pretty' -d ' {

    "name": "John Doe" }' { "_index" : "customer", "_type" : "external", "_id" : "1", "_version" : 1, "created" : true } curl -XGET 'localhost:9200/customer/external/1?pretty' { "_index" : "customer", "_type" : "external", "_id" : "1", "_version" : 1, "found" : true, "_source" : { "name": "John Doe" } }
  7. Update Document curl -XPOST 'localhost:9200/customer/external/1/_update? pretty' -d ' { "doc":

    { "name": "Jane Doe" } }' curl -XPOST 'localhost:9200/customer/external/1/_update? pretty' -d ' { "doc": { "name": "Jane Doe", "age": 20 } }' curl -XPOST 'localhost:9200/customer/external/1/_update? pretty' -d ' { "script" : "ctx._source.age += 5" }'
  8. Batch Processing curl -XPOST 'localhost:9200/customer/external/_bulk?pretty' -d ' {"index":{"_id":"1"}} {"name": "John

    Doe"} {"index":{"_id":"2"}} {"name": "Jane Doe"} ' curl -XPOST 'localhost:9200/customer/external/_bulk?pretty' -d ' {"update":{"_id":"1"}} {"doc": { "name": "John Doe becomes Jane Doe" } } {"delete":{"_id":"2"}} '
  9. Search API https://www.elastic.co/guide/en/elasticsearch/reference/curr ent/search.html • Request body (sort, fields, post

    filter, highlighting, explain) • Suggester Query DSL https://www.elastic.co/guide/en/elasticsearch/reference/curr ent/query-dsl.html • Fuzzy term query Mapping https://www.elastic.co/guide/en/elasticsearch/reference/cur rent/mapping.html • Field boosting
  10. Clients https://www.elastic.co/guide/en/elasticsearch/client/index.html • Java API [2.1] • JavaScript API •

    Groovy API [2.1] • .NET API • PHP API [2.0] • Perl API • Python API • Ruby API • Community Contributed Clients
  11. Perbandingan • solr vs elasticsearch http://solr-vs-elasticsearch.com/ • Database vs Full

    text search http://www.ideaeng.com/database-full-text-search-0201