About Elastic search:
-Near real time
search platform
-Each index can be
horizontally splitted into multiple shards.
Each shards can
have own replicas.
Replication helps
in
-High availability
-Scale out search /throughput,
as search can be executed on replicas in
parallel
Steps to setup elastic search:
1. Adding Schema:
PUT / INDEX_NAME
"mappings":
{
"Index_name": {
}
,
"settings": {
"index": {
"number_of_replicas": "1",
"number_of_shards": "1"
}
}
}
2. Add Domain Schema (equivalent to table)
PUT /index_name
{
"mappings": {
"index_type": {
"properties": {
"firstName": {
"type": "string"
},
"secondName": {
"type": "string"
},
"location": {
"type": "string"
"index": "not_analyzed"
}
}
}
PUT index_name/index_type/documentId1
{
"firstName" :" hello",
"secondName": "world"
"location"": "Malesia-Singapore"
}
GET INDEX_NAME/
INDEX_TYPE/Id
PUT INDEX_NAME / INDEX_TYPE
/1
{
"body": "here"
}
DELETE index_name/index_type/<id>
Query search :
GET INDEX_NAME
{
"query" : {
<json_query>
}
}
All search:
All search:
GET INDEX_NAME/INDEX_TYPE/_search{
GET _search
{
"query": {
"match_all": {}
}
}
Executing term query
Executing term query
get index_name/index_type/_search
{
"query": {
"term": {
"location": "Malesia-Singapore"
}
}
}