# Difference between Hits and Hits(total)

**URL:** <https://discuss.elastic.co/t/difference-between-hits-and-hits-total/326798>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [March 1, 2023, 6:35pm UTC](https://discuss.elastic.co/t/difference-between-hits-and-hits-total/326798 "2023-03-01T18:35:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joerg55](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@joerg55](https://discuss.elastic.co/u/joerg55)\
**Post date:** [March 1, 2023, 6:35pm UTC](https://discuss.elastic.co/t/difference-between-hits-and-hits-total/326798/1 "2023-03-01T18:35:41Z")

</div>

Hi at all,

I'm new here and am trying to create a few charts with vega-lite. With some help from here some bars are to be seen. But I have a problem with the amount of records wich are given from the request. Although my index contains 12 records the result of the request delivers only 10.

 ![vega01](https://us1.discourse-cdn.com/elastic/original/3X/3/9/391b3c2acd2c69103374bb6fec7fb902a29b2a0a.jpeg)

The request looks like that:

```auto
{
  "query": {
    "bool": {
      "must": [],
      "filter": [],
      "should": [],
      "must_not": []
    }
  }
}

```

A common chart created in lens shows all 12 records. What is the reason for the differnce?

Thanks in advance  
Joerg

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [March 1, 2023, 9:42pm UTC](https://discuss.elastic.co/t/difference-between-hits-and-hits-total/326798/2 "2023-03-01T21:42:11Z")

</div>

"Hits" refers to the number of hits actually returned from the query. This is limited by the `size` parameter sent in the request to Elasticsearch (which defaults to 10).

"Hits (total)" refers to the total number of hits that match the query, not the number of results returned.

---

<div class="post-metadata">

**Author:** ![joerg55](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@joerg55](https://discuss.elastic.co/u/joerg55)\
**Post date:** [March 2, 2023, 9:18am UTC](https://discuss.elastic.co/t/difference-between-hits-and-hits-total/326798/3 "2023-03-02T09:18:56Z")

</div>

@thank u lukas.

with a little bit try and error I found now that the 'size' is to be placed into a body-tag. The next step for me is to sort the data. That works fine within the console

```auto
post umsatz06/_search
{
  "query": {
    "bool": {
      "must": [],
      "filter": [],
      "should": [],
      "must_not": []
    }
  },
  "size":"12",
  "sort":"Umsatz"
}

```

but it fails in the context of my chart

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "A simple bar chart",
  "data": {
    "url": {
        "index":"umsatz06",
        "%context%":true,
        "body":{
          "size":12,
          "sort":"Umsatz"
        }
    }
    "format": {"property": "hits.hits"}
  },
  "mark": "bar",
  "encoding": {
    "x": {"field": "_source.Monat" "type": "nominal", "axis": {"labelAngle": 0}},
    "y": {"field": "_source.Umsatz" "type": "quantitative"}
  }
}

```

So my intention is not that the community build my charts. I would be very happy, if you can show me these parts of documentation which describe the DATA- and the URL-part that I have to use to get success.

regards joerg

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 30, 2023, 9:19am UTC](https://discuss.elastic.co/t/difference-between-hits-and-hits-total/326798/4 "2023-03-30T09:19:03Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
