
Elasticsearch is a distributed search engine built on Apache Lucene. In fact, Elasticsearch is an independent database, written in Java. It’s called “distributed” because it enables clustering – that is, running multiple instances of the same application together as one, allowing you to build a genuinely large and high-performance database that can ingest batch data in many advanced formats. Best of all, it enables fast full-text search and is easy for developers to work with, since communication with Elasticsearch happens via JSON.
If your company deals with large data sets, Elasticsearch is designed exactly for you.
At Remote Admin, we’ll build you a suitable server environment that uses this highly efficient, non-relational database, and your developers will be able to connect their application to it very easily.
Elasticsearch listens on port 9200 on the localhost interface. So we send everything over HTTP and get JSON back in return, for example:
{
“status” : 200,
“name” : “Big Man”,
“cluster_name” : “elasticsearch”,
“version” : {
“number” : „1.7.2”,
“build_hash” : “e43676b1385b8125d647f593f7202acbd816e8ec”,
“build_timestamp” : „2015-09-14T09:49:53Z”,
“build_snapshot” : false,
“lucene_version” : „4.10.4”
},
“tagline” : „You Know, for Search”
}
The search process is just as simple:
{
“took” : 85,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“failed” : 0
},
“hits” : {
“total” : 3,
“max_score” : 1.0,
“hits” : [ {
“_index” : “blog”,
“_type” : “post”,
“_id” : “1”,
“_score” : 1.0, “_source” :
{
“user”: “dilbert”,
“postDate”: “2011-12-15”,
“body”: „Search is hard. Search should be easy.” ,
“title”: “On search”
}
}, {
“_index” : “blog”,
“_type” : “post”,
“_id” : “2”,
“_score” : 0.30685282, “_source” :
{
“user”: “dilbert”,
“postDate”: “2011-12-12”,
“body”: „Distribution is hard. Distribution should be easy.” ,
“title”: “On distributed search”
}
}, {
“_index” : “blog”,
“_type” : “post”,
“_id” : “3”,
“_score” : 0.30685282, “_source” :
{
“user”: “dilbert”,
“postDate”: “2011-12-10”,
“body”: „Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat” ,
“title”: “Lorem ipsum”
}
} ]
}
The purpose of this short piece was to show what Elasticsearch is and how to handle large volumes of data in a way other than simply adding more servers running MySQL or PostgreSQL.
The code examples were taken from elasticsearchtutorial.
