Elasticsearch is a highly scalable and distributed open source search and analytics engine. It allows storing, searching, and analyzing large volumes of data quickly. Elasticsearch is built on top of Lucene and implemented in Java, allowing it to be cross-platform. Documents are indexed into indexes, which can contain multiple index types and be split into shards for scalability and replicas for availability. Commands are used to manage and query indexes, including creating, indexing, updating, deleting documents and searching across all documents.
2. What is Elastic Search?
? Elastic Search is a highly scalable, distributed,
open-source, full-text search and analytics
engine.
? Allows you to store, search, and analyze big
volumes of data quickly and in near real
time. Near RealTime (NRT) search platform. There is a slight latency
(normally one second) from the time you index a document until the time it becomes
searchable.
? Built on top of Lucene, implemented in Java
(cross platform)
4. Basic Concepts
? Cluster (default name: elasticsearch)
? Nodes (default name: a random marvel character name)
? Index (collection of documents)
? IndexType (Mandatory. Logical partition of an index, data actually
physically resides in Index)
? Document (Basic unit of indexable info, physically resides in index,
must be assigned to a type)
? Shards (Index can be split into multiple shards, default 5, spread over
nodes. Each shard is a LUCENE index internally.
? Replica (A shard may be either Primary Shard or Replica Shard, default
replicas=1)
9. Commands
? Starting Elastic Search
./elasticsearch --cluster.name my_cluster_name --node.name my_node_name
? Check Cluster Health
GET localhost:9200/_cat/health
? List Nodes
GET localhost:9200/_cat/nodes
? List Indices
GET localhost:9200/_cat/indices
? Create Index
PUT localhost:9200/<index name>
10. Commands (…contd)
? Index/Replace a document
PUT localhost:9200/<index name>/<type name>/<ID>
{
"field1" : "value1",
"field2" : "value2"
}
? Retrieve a document
GET localhost:9200/<index name>/<type name>/<ID>
? Delete an Index
DELETE localhost:9200/<index name>
? Update a Document
POST localhost:9200/<index name>/<type name>/<ID>/_update
{
"doc": { "field1": "value1", "field2": value2 }
}
12. Search API
? Elastic Search has its own JSON-style query
DSL.
? Two basic ways to send search parameters:
1.Through REST Request URI
GET localhost:9200/<index name>/_search?q=*
2.Through REST Body
POST localhost:9200/<index name>/_search
{
"query": { "match_all": {} }
}