AI Hints
Home›Elasticsearch Tutorial›Your First Searches
Elasticsearch · Lesson 23 of 120

Reading the Response

Took, hits and scores.

⏱ 2 min read▶ Video at 20:58🎓 Free
Watch this lesson in the Elasticsearch courseWatch on YouTube ↗Full Elasticsearch course

A search response tells you more than just the results. It says how long the search took, how many documents matched, and how good each match is.

  • How long
  • How many
  • How good

A full response

We search names for boots, and ask for one result. Run it. Took is the time in milliseconds. Total is how many products matched. Max score is the best score. And each hit has its ID, its score, and its source.

Dev Tools Consoletext
GET products/_search?filter_path=took,hits.total,hits.max_score,hits.hits._id,hits.hits._score,hits.hits._source.name
{
  "query": { "match": { "name": "boots" } },
  "size": 1
}
Output
{
  "took": 1,
  "hits": {
    "total": {"value": 3, "relation": "eq"},
    "max_score": 2.7963,
    "hits": [
      {
        "_id": "26",
        "_score": 2.7963,
        "_source": {"name": "Trail Hiking Boots"}
      }
    ]
  }
}
Also uses _load
products

Response fields

Took is the search time. Hits total value is the number of matches. Relation e q means that number is exact. Score says how relevant each hit is, and hits are sorted by it, highest first.

keyvalue
tooktime in ms
hits.total.valuenumber of matches
relation: eqthe count is exact
_scorerelevance, highest first

Summary

Took is the time, total is the number of matches, and each hit has a score. Results come sorted, best first. Next, the match query.

Key takeaways
  • took
  • hits.total
  • _score
Next up: The match Query — full-text search