What is Elasticsearch?

Elasticsearch is a search server based on Lucene. It provides a distributed, multitenant-capable full-text search engine with a RESTful web interface and schema-free JSON documents. Elasticsearch is developed in Java and is released as open source under the terms of the Apache License

What is Apache Lucene ?

Apache Lucene is a high-performance, full featured text search engine library written entirely in Java. It is a technology suitable for nearly any application that requires full-text search, especially cross-platform.

Features :

  •     Real time analytics
  •     Distributed
  •     High availability
    • —   Automatic discovery of peers in a cluster
  •     Multi tenant architecture
  •     Full text
  •     Document oriented
  •     Schema free
  •     RESTful API
  •     Per-operation persistence
  •     Easy to extend with a plugin system for new functionality

Terminology:

Elasticsearch terminology with relational database
Elasticsearch terminology with relational database

Document :

In Elasticsearch, everything is stored as a Document. Document can be addressed and retrieved by querying their attributes.

$ curl -XGET http://localhost:9200/gems/document/pry-0.5.9

Document
Document

Shard:

Shard Each Shard is a separate native Lucene Index.

Replica:

An exact copy of primary Shard. Helps in setting up High Availability, increases query throughput.

Index :

ElasticSearch stores its data in logical Indices. Think of a table,collection or a database. •

An Index has at-least 1 primary Shard, and 0 or more Replicas.

Elasticsearch Index
Elasticsearch Index

Cluster :

A collection of cooperating ElasticSearch nodes. Gives better availability and performance via Index Sharding and Replicas.

Installation:

Download and unzip the latest Elasticsearch distribution. You can download from official website  https://www.elastic.co/downloads/elasticsearch

or Linux user can download package using curl

$ curl -L -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.4.tar.gz

Then extract it as follows (Windows users should unzip the zip package):

  $ tar -xvf elasticsearch-1.4.4.tar.gz

For Unix run OS installation Run

   $ bin/elasticsearch 

For Windows installation Run bin/elasticsearch.bat

Verify Installation:-

Run curl -X GET http://localhost:9200/

Picture4

Note:ElasticSearch is built using Java, and requires at least Java 6 in order to run.

RESTful interface :-

Picture3
How to add Index :-

To index that we decide on an index name (“orders”), a type name (“order”) and an id (“1”) and make a request following the pattern described above with the JSON object in the body.

curl -XPUT "http://localhost:9200/orders/order/1" -d'{
 "product_name": "Product XYZ",
 "prodict_description": "Lorem ispum.....",
 "price": 10001
 }'

The _search endpoint

  • http://serverName:9200/_search

 Search across all indexes and all types.

  • http://serverName:9200/orders/_search

Search across all types in the orders index.

  • http://serverName:9200/orders/order/_search

Search explicitly for documents of type order the orders index

Download :

(Visited 124 times, 5 visits today)