ElasticSearch Flashcards
Elasticsearch is an open-source _______ built on top of _________
search engine; Apache Lucene
What is Apache Lucene
Apache Lucene is a fulltext search-engine library
What does REST stand for?
representational state transfer
What is RESTful service?
A RESTful service is one that implements REST pattern.
What is REST?
REST, or REpresentational State Transfer, is an architectural style for providing standards between computer systems on the web, making it easier for systems to communicate with each other.
There are 4 basic HTTP verbs we use in requests to interact with resources in a REST system:
- GET — retrieve a specific resource (by id) or a collection of resources
- POST — create a new resource
- PUT — update a specific resource (by id)
- DELETE — remove a specific resource by id
- For ES - HEAD
What is ElasticSearch
- Enables full-text search
- A distributed real-time document store where every field is indexed and searchable
- A distributed search engine with real-time analytics
- Capable of scaling to hundreds of servers and petabytes of structured and
unstructured data
What is a node?
A node is a running instance of Elasticsearch.
What is a cluster
A cluster is a group
of nodes with the same cluster.name that are working together
to share data and to provide failover and scale, although a single
node can form a cluster all by itself.
All other languages can communicate with Elasticsearch over port _______ using a
_______, accessible with your favorite web client.
9200 ; RESTful API
A request to Elasticsearch consists of the same parts as any HTTP request:
curl -X ‘:///?’ -d ‘’
What is a protocol
Either http or https
What is HOST
The hostname of any node in your Elasticsearch cluster, or localhost for a node on your local machine.
What is PORT
The port running the Elasticsearch HTTP service, which defaults to 9200.
What is QUERY_STRING
Any optional query-string parameters (for example ?pretty will pretty-print the
JSON response to make it easier to read.)
What is BODY
A JSON-encoded request body (if the request needs one.)
For instance, to count the number of documents in the cluster, we could use
curl -XGET 'http://localhost:9200/_count?pretty' -d ' { "query": { "match_all": {} } }
shorthand format:
GET /_count { "query": { "match_all": {} } }
Elasticsearch is _______- oriented, meaning that it stores entire ___________
document; objects or documents.
How does elastic search makes a document searchable?
It indexes the contents of the documents to make it searchable
In Elasticsearch, you index, search, sort, and filter ________; not __________
This is a fundamentally different way of thinking about
data and is one of the reasons Elasticsearch can perform complex _________
documents; rows of columnar data; full-text search.
Relational DB ⇒ Databases ⇒ Tables ⇒ Rows ⇒ Columns
ElasticSearch => Indices => Types => Documents => Fields
What is an Index?
Index is like a databases. A place to store the documents.
What is indexing (verb)
To index a document in a index(noun) so it can be retrieved or queried
Insert a document
PUT /meijer/households/1 { "primary_tender" : "12312321" "primary_customer": "23123213" }
How to retrieve a document?
GET /meijer/households/1
Simplest search?
GET /meijer/households/_search //retrieves everything
GET /meijer/households/_search displays how many results.
By default it retrieve the top 10 results.
Lightweight search to get the customer = 1234
GET /meijer/households/_search?q=primary_customer:1234
ElasticSearch DSL search to get the customer = 1234
GET /meijer/households/_search { "query": { "match" : { "primary_customer":"1234" } } }
ElasticSearch DSL search history to get the customer = 1234 and dm_flag = true
GET /meijer/households/_search { "query": { "filtered": { "filter": { "range":{ "age":{ "gt":30 } } }, "match": { "customer":"1234" } } } }
What is relevance score?
How well the document matches the query
By default, Elasticsearch sorts matching results by their _________
relevance score
Elasticsearch vs RDMS
Relevance score is the major difference. In RDBMS the term either matches or not