Slide 1

Slide 1 text

menggunakan elastic search

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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.

Slide 5

Slide 5 text

# node # cluster # shard (index.number_of_shards: 5) indexing >> #replica (index.number_of_replicas: 5) searching >>

Slide 6

Slide 6 text

# node.master true / false # node.data true / false # path.data default: /var/lib/elasticsearch nfs: /media/different_media * type category / partition * document json

Slide 7

Slide 7 text

Start elasticsearch server $ sudo service elasticsearch start $ sudo /bin/systemctl start elasticsearch.service $ bin/elasticsearch

Slide 8

Slide 8 text

Create Index curl -XPUT 'localhost:9200/customer?pretty' { "acknowledged" : true }

Slide 9

Slide 9 text

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" } }

Slide 10

Slide 10 text

Delete Index curl -XDELETE 'localhost:9200/customer?pretty' { "acknowledged" : true }

Slide 11

Slide 11 text

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" }'

Slide 12

Slide 12 text

Delete Document curl -XDELETE 'localhost:9200/customer/external/2?pretty'

Slide 13

Slide 13 text

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"}} '

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

Perbandingan ● solr vs elasticsearch http://solr-vs-elasticsearch.com/ ● Database vs Full text search http://www.ideaeng.com/database-full-text-search-0201