william007
william007

Reputation: 18547

Elastic search shards - total, successful, failed

This is the results

{
  "_index": "vehicles",
  "_id": "123",
  "_version": 2,
  "result": "updated",
  "_shards": {
    "total": 2,
    "successful": 1,
    "failed": 0
  },
  "_seq_no": 1,
  "_primary_term": 1
}

for query

PUT /vehicles/_doc/123
{
  "make": "Honda",
  "color": "Blue",
  "HP": 250,
  "milage": 24000,
  "price": 19300.97
}

on elastic search 8.

May I know

  1. The total shards (which is 2) does it include primary shard + replica shard?
  2. The successful shards - I supposed that's the primary shard where the put is written into - can it be more than 1?
  3. The failed - I supposed it's the failed primary shard?

Upvotes: 0

Views: 1743

Answers (2)

Musab Dogan
Musab Dogan

Reputation: 3690

Search API official documentation if needed to someone: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html

  1. _shards.total: Total number of shards that require querying, including unallocated shards.
  2. _shards.successful: Number of shards that executed the request successfully.
  3. _shards.skipped: Number of shards that skipped the request because a lightweight check helped realize that no documents could possibly match on this shard. This typically happens when a search request includes a range filter and the shard only has values that fall outside of that range.
  4. _shards.failed: Number of shards that failed to execute the request. Note that shards that are not allocated will be considered neither successful nor failed. Having failed+successful less than total is thus an indication that some of the shards were not allocated.

Upvotes: 1

Val
Val

Reputation: 217554

As explained in the official documentation for the Index API response body:

  • _shards.total tells you how many shard copies (primaries + replicas) the index operation should be executed on
  • _shards.successful returns the number of shard copies the index operation succeeded on. Upon success, successful is at least 1, like in your case. Since by default, write operations only wait for the primary shards to be active before proceeding, only 1 is returned. If you want to see 2, then you need to add wait_for_active_shards=all in your indexing request
  • _shards.failed contains replication-related errors in the case an index operation failed on a replica shard. 0 indicates there were no failures.

Upvotes: 3

Related Questions