O'Reilly logo

Node.js 8 the Right Way by Jim Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing an Elasticsearch Query Command

Now that the documents are in the index, we can start querying for them. First we’ll take a look around using the existing get command, and then we’ll implement a specific command just for querying.

The Elasticsearch API endpoint we want to hit is /_search. We can already hit this endpoint using the get command. Let’s try that now.

 $ ​​./esclu​​ ​​get​​ ​​'_search'​​ ​​|​​ ​​jq​​ ​​'.'​​ ​​|​​ ​​head​​ ​​-n​​ ​​20
 {
  "took": 3,
  "timed_out": false,
  "_shards": {
  "total": 5,
  "successful": 5,
  "failed": 0
  },
  "hits": {
  "total": 53212,
  "max_score": 1,
  "hits": [
  {
  "_index": "books",
  "_type": "book",
  "_id": "pg100",
  "_score": 1,
  "_source": {
  "id": 100,
  "title": "The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required