Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying ElasticSearch Cookbook
  • Table Of Contents Toc
ElasticSearch Cookbook

ElasticSearch Cookbook - Second Edition

By : Alberto Paro
4.1 (7)
close
close
ElasticSearch Cookbook

ElasticSearch Cookbook

4.1 (7)
By: Alberto Paro

Overview of this book

If you are a developer who implements ElasticSearch in your web applications and want to sharpen your understanding of the core elements and applications, this is the book for you. It is assumed that you’ve got working knowledge of JSON and, if you want to extend ElasticSearch, of Java and related technologies.
Table of Contents (14 chapters)
close
close
13
Index

Using an ID query/filter


The ID query/filter allows you to match documents by their IDs.

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...

In order to execute ID queries/filters, perform the following steps:

  1. The ID query to fetch IDs 1, 2, 3 of the type test-type is in this form:

    curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search?pretty=true' -d '{
      "query": {
        "ids" : {
          "type" : "test-type",
          "values" : ["1", "2", "3"]
        }
      }
    }'
    
  2. The same query can be converted to a filter query, similar to this one:

    curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search?pretty=true' -d '{
      "query": {
        "filtered": {
          "filter": {
            "ids" : {
              "type" : "test-type",
              "values" : ["1", "2", "3"]
            }
          },
          "query": {
            "match_all": {}
          }
        }
      }
    }'
    

How it works...

Querying/filtering by...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
ElasticSearch Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon