<commit_before>[[docs-index_]]
== Index API

The index API adds or updates a typed JSON document in a specific index,
making it searchable. The following example inserts the JSON document
into the "twitter" index, under a type called "tweet" with an id of 1:

[source,js]
--------------------------------------------------
PUT twitter/tweet/1
{
    "user" : "kimchy",
    "post_date" : "2009-11-15T14:12:12",
    "message" : "trying out Elasticsearch"
}
--------------------------------------------------
// CONSOLE

The result of the above index operation is:

[source,js]
--------------------------------------------------
{
    "_shards" : {
        "total" : 2,
        "failed" : 0,
        "successful" : 2
    },
    "_index" : "twitter",
    "_type" : "tweet",
    "_id" : "1",
    "_version" : 1,
    "created" : true,
    "result" : created
}
--------------------------------------------------
// TESTRESPONSE[s/"successful" : 2/"successful" : 1/]

The `_shards` header provides information about the replication process of the index operation.

* `total` - Indicates to how many shard copies (primary and replica shards) the index operation should be executed on.
* `successful`- Indicates the number of shard copies the index operation succeeded on.
* `failures` - An array that contains replication related errors in the case an index operation failed on a replica shard.

The index operation is successful in the case `successful` is at least 1.

NOTE:   Replica shards may not all be started when an indexing operation successfully returns (by default, only the 
        primary is required, but this behavior can be <<index-wait-for-active-shards,changed>>). In that case, <commit_msg>Update index_.asciidoc (#20125)<commit_after>[[docs-index_]]
== Index API

The index API adds or updates a typed JSON document in a specific index,
making it searchable. The following example inserts the JSON document
into the "twitter" index, under a type called "tweet" with an id of 1:

[source,js]
--------------------------------------------------
PUT twitter/tweet/1
{
    "user" : "kimchy",
    "post_date" : "2009-11-15T14:12:12",
    "message" : "trying out Elasticsearch"
}
--------------------------------------------------
// CONSOLE

The result of the above index operation is:

[source,js]
--------------------------------------------------
{
    "_shards" : {
        "total" : 2,
        "failed" : 0,
        "successful" : 2
    },
    "_index" : "twitter",
    "_type" : "tweet",
    "_id" : "1",
    "_version" : 1,
    "created" : true,
    "result" : created
}
--------------------------------------------------
// TESTRESPONSE[s/"successful" : 2/"successful" : 1/]

The `_shards` header provides information about the replication process of the index operation.

* `total` - Indicates to how many shard copies (primary and replica shards) the index operation should be executed on.
* `successful`- Indicates the number of shard copies the index operation succeeded on.
* `failed` - An array that contains replication related errors in the case an index operation failed on a replica shard.

The index operation is successful in the case `successful` is at least 1.

NOTE:   Replica shards may not all be started when an indexing operation successfully returns (by default, only the 
        primary is required, but this behavior can be <<index-wait-for-active-shards,changed>>). In that case, 
{'fraction_non_alphanumeric': 0.20713867758923346, 'fraction_numerical': 0.0155061439438268, 'mean_word_length': 2.1834264432029795, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '911292', 'n_tokens_mistral': 956, 'n_tokens_neox': 913, 'n_words': 380}