HTTP Methods: GET, PUT, POST, DELETE
Syntax:
<HTTP_METHOD><SERVER:PORT>/<INDEX_NAME>/_doc/<DOC_ID>
GET books/_count Counts the total number of documents in the index
GET <index>/_doc/<id> Retrieve a single document
Phrases with missing words
For example, instead of searching for “Elasticsearch in action”, users may search for “Elasticsearch
action”. To honour this, we set match_phrase with a slop parameter. A slop expects a positive
integer indicating how many words that the phrase is missing when searching. The query in the
listing 2.15 here has been set with a slop of 1, indicating one word is missing in the phrase that’s
been searched:
Elasticsearch treats the structured and unstructured data in different ways: the
unstructured (fulltext) data gets analyzed, while the structured fields are stored as is.
The set of queries that are performed on structured text are called term-level
queries. They produce a binary output: fetch the result if the query matches with the
criteria. They will not consider how well the documents match (relevant) instead
they concentrate on whether the query has a match or not. As relevancy is not
considered, the term level queries do not produce a relevancy score.
Compound queries combine individual queries called leaf queries to build powerful
and robust queries providing us the capability to cater to complex scenarios. Some of
the compound queries are,
Boolean (bool) query,
Constant score (constant_score) query
Function (function_score) score,
Boosting (boosting) query
Disjunction max (dis_max) query
While searching helps us find a needle in the haystack, aggregations, on the other
hand, help zoom out to establish a summary of our data, like the total number of
server errors in the last one-hour, average book sales in the third quarter, classifying
the movies by their gross earnings and so on.
Analytics enables organizations to find insights into the data. So far, we've looked at
searching for the documents from a given corpus of documents. Analytics is looking
at the big picture and analyzing the data from a very high level to draw conclusions
about it.
Aggregations fall into three categories,
Metric aggregations—Simple aggregations like sum, min, max, and average
fall into this category of aggregations. They provide an aggregate value across
a set of document data
Bucket aggregations—Bucket aggregations help collect data into buckets,
segregated by intervals like days, age groups, etc. These help us build
histograms, pie charts and other visualizations.
Pipeline aggregations—Pipeline aggregations work on the output from the
other aggregations.