Tutorial: elastic search

Install and configure elastic search:

  1. Download and install package

    cd /tmp
    wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.4.0/elasticsearch-2.4.0.deb
    sudo dpkg -i elasticsearch-2.4.0.deb
    mkdir /esdata/different_media
  2. Enable elastic search server

    sudo systemctl enable elasticsearch.service
    
  3. Configure elastic search server

    sudo nano /etc/elasticsearch/elasticsearch.yml

    Contents to change:

    cluster.name: myescluster
    node.name: "esnode1"
    node.master: true
    node.data: true
    index.number_of_shards: 1
    index.number_of_replicas: 0
    path.data: /esdata/different_media
    
  4. Check elastic search configuration

    sudo systemctl restart elasticsearch
    curl -XGET 'http://localhost:9200/_nodes?pretty'
  5. Use elastic search rest api

    Add data:
    curl -X POST 'http://localhost:9200/my-index/my-type/1' -d '{ "message": "Hello ES!" }'
    Retrieve data:
    curl -X GET 'http://localhost:9200/my-index/my-type/1'
    Change data:
    curl -X PUT 'localhost:9200/my-index/my-type/1?pretty' -d '
    {
        "message": "Hello ES - new text!"
    }'
    Delete data:
    curl -XDELETE 'http://localhost:9200/my-index/my-type/1'
    Search data:
    curl -XGET "http://localhost:9200/my-index/my-type/_search?q=Hello&pretty=true'
    Search parameter:
    curl -XPOST "http://localhost:9200/my-index/_search " -d'
    {
        "query": {
            "match": {
                "timessagetle" : {
                "query": "Hello",
                "fuzziness": 2
                }
            }
        }
    }'

If you need more information about elasticsearch visit their tutorials: https://www.elastic.co/guide/en/elasticsearch/guide/current/intro.html