Executing a search

ElasticSearch was born as a search engine; its main work is to process queries and give results.

In this recipe, we'll see that a search in ElasticSearch is not just limited to matching documents but can also calculate additional information required to improve the search quality.

Getting ready

You need a working ElasticSearch cluster and an index populated with the script chapter_05/populate_query.sh, available in the code bundle for this book.

How to do it...

To execute a search and view the results, perform the following steps:

  1. From the command line, execute a search, as follows:
    curl -XGET 'http://127.0.0.1:9200/test-index/test-type/_search' -d '{"query":{"match_all":{}}}'
    

    In this case, we have used a match_all query which means ...

Get ElasticSearch Cookbook - Second Edition 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.