Skip to content

Instantly share code, notes, and snippets.

@geekpete
Last active April 20, 2020 04:49
Show Gist options
  • Save geekpete/38c06b2eaf2745c3b7312d329acb01fd to your computer and use it in GitHub Desktop.
Save geekpete/38c06b2eaf2745c3b7312d329acb01fd to your computer and use it in GitHub Desktop.
Trying to repro the docs example for Terms agg doc counts being approximate

NB, the shard numbers that the batches hash to are different in 6.8, but each batch still goes to separate shards. 6.8 results in the same result as 7.x attempts.

DELETE /test-term-agg
PUT /test-term-agg
{
  "settings": {
    "number_of_shards": 3
  },
  "mappings": {
    "_doc": {
      "properties": {
        "product": {
          "type": "keyword"
        }
      }
    }
  }
}



# this routing key will land documents in only shard 0 we'll call it Shard A
POST /_bulk?refresh
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product C" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product C" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product C" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product C" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product C" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product C" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product D" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product D" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product D" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product E" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product E" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product F" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product F" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product G" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product G" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product H" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product H" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product I" }
{ "index" : { "_type":"_doc", "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product J" }


# this routing key will land documents only in shard 1 - we'll call it Shard B
POST /_bulk?refresh
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product B"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product F"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product I"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product I"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product I"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product I"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product I"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product I"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product I"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product I"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product I"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product I"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Q"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Q"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Q"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Q"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Q"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product Q"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product J"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product J"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product J"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product J"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product J"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product J"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"zzz"}}
{"product":"Product C"}



# this routng key will land documents only in shard 2 - we'll call it Shard C
POST /_bulk?refresh
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product A"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product C"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Z"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product G"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product E"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product H"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Q"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product Q"}
{"index":{"_type":"_doc","_index":"test-term-agg","routing":"1ggg"}}
{"product":"Product D"}

# first check the per-shard Product document counts
# should match up with the first table in the docs link:
# "The terms for each of the three shards are shown below with their respective document counts in brackets:"


# check doc counts per product in Shard A
GET /test-term-agg/_search?preference=_shards:0
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 1000,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}

# check doc counts per product in Shard B
GET /test-term-agg/_search?preference=_shards:1
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 1000,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}

# check doc counts per product in Shard C
GET /test-term-agg/_search?preference=_shards:2
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 1000,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}


# now check top 5 product docs per shard
# should match up with counts in the second table in the docs
# "The shards will return their top 5 terms so the results from the shards will be:"

# check top 5 terms in shard A
GET /test-term-agg/_search?preference=_shards:0
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 5,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}

# check top 5 terms in shard B
GET /test-term-agg/_search?preference=_shards:1
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 5,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}

# check top 5 terms in shard C
GET /test-term-agg/_search?preference=_shards:2
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 5,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}

# now try the top 5 product terms across all shards
# doesn't match up with the third table in the docs
# "Taking the top 5 results from each of the shards (as requested) and combining them to make a final top 5 list produces the following:"

# top 5 product terms combined - doesn't seem to match up with the docs
GET /test-term-agg/_search
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 5,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}

From Document counts are approximate

  • Tested on 7.6.0, 7.5.0, 7.0.0
  • Tested on 6.8 also, with slight difference due to types.
  • Recreate the test data using routing to inject specific shards with specific documents
  • End up with the same confirmed doc counts of each Product type per shard as the docs
  • Verify the top 5 per shard agg (using shard preference) matches the docs
  • For some reason the top 5 across all shards doesn't match, am I reading the docs wrong?
DELETE /test-term-agg
PUT /test-term-agg
{
  "settings": {
    "number_of_shards": 3
  },
  "mappings": {
    "properties": {
      "product": {
        "type": "keyword"
      }
    }
  }
}



# this routing key will land documents in only shard 0 we'll call it Shard A
POST /_bulk?refresh
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product D" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product D" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product D" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product I" }
{ "index" : { "_index" : "test-term-agg", "routing": "asdfasdfasdf" } }
{ "product" : "Product J" }


# this routing key will land documents only in shard 1 - we'll call it Shard B
POST /_bulk?refresh
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product B" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product F" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product I" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product I" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product I" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product I" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product I" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product I" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product I" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product I" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product I" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product I" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Q" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Q" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Q" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Q" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Q" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product Q" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product J" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product J" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product J" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product J" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product J" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product J" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "zzz" } }
{ "product" : "Product C" }



# this routng key will land documents only in shard 2 - we'll call it Shard C
POST /_bulk?refresh
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product A" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product C" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Z" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product G" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product E" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product H" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Q" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product Q" }
{ "index" : { "_index" : "test-term-agg", "routing": "1ggg" } }
{ "product" : "Product D" }

# first check the per-shard Product document counts
# should match up with the first table in the docs link:
# "The terms for each of the three shards are shown below with their respective document counts in brackets:"


# check doc counts per product in Shard A
GET /test-term-agg/_search?preference=_shards:0
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 1000,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}

# check doc counts per product in Shard B
GET /test-term-agg/_search?preference=_shards:1
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 1000,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}

# check doc counts per product in Shard C
GET /test-term-agg/_search?preference=_shards:2
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 1000,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}


# now check top 5 product docs per shard
# should match up with counts in the second table in the docs
# "The shards will return their top 5 terms so the results from the shards will be:"

# check top 5 terms in shard A
GET /test-term-agg/_search?preference=_shards:0
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 5,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}

# check top 5 terms in shard B
GET /test-term-agg/_search?preference=_shards:1
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 5,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}

# check top 5 terms in shard C
GET /test-term-agg/_search?preference=_shards:2
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 5,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}

# now try the top 5 product terms across all shards
# doesn't match up with the third table in the docs
# "Taking the top 5 results from each of the shards (as requested) and combining them to make a final top 5 list produces the following:"

# top 5 product terms combined - doesn't seem to match up with the docs
GET /test-term-agg/_search
{
  "aggs": {
    "products": {
      "terms": {
        "field": "product",
        "size": 5,
        "show_term_doc_count_error": true
      }
    }
  },
  "size": 0
}

:philosoraptor:

@geekpete
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment