Chapter 7. Full-Body Search
Search lite—a query-string search—is useful for ad
hoc queries from the command line. To harness the full power of search,
however, you should use the request body search
API, so called because
most parameters are passed in the HTTP request body instead of in the query
string.
Request body search—henceforth known as search—not only handles the query itself, but also allows you to return highlighted snippets from your results, aggregate analytics across all results or subsets of results, and return did-you-mean suggestions, which will help guide your users to the best results quickly.
Empty Search
Let’s start with the simplest form of the search
API, the empty search,
which returns all documents in all indices:
GET
/
_search
{}
Just as with a query-string search, you can search on one, many, or _all
indices, and one, many, or all types:
GET
/
index_2014
*
/type1,type2/_search
{}
And you can use the from
and size
parameters for pagination:
GET
/
_search
{
"from"
:
30
,
"size"
:
10
}
Get Elasticsearch: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.