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

Get Node.js 8 the Right Way 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.