Replica node response to primary

During indexing process, indexing is first performed on primary and if successful , perform on replica which on successfully indexing response back to primary. can someone explain me what process is involved in getting successful/failed response from replica to primary.(I mean doc Id or request Id or something).
can someone point to the code base of elasticsearch where replica shards sends back successful indexing response to primary so that success message is given back to client requested for an indexing.


The response from the replica to the primary is managed via the same mechanism that all other request/responses are managed in Elasticsearch: via request IDs at the transport layer. The underlying framework for these requests is TransportReplicationAction. Is there a more specific question that you have?

Thanks jasontedor for your reply ,I debugged and found out request id generated corresponding to my doc which is sent to replica for its indexing.But I have a small doubt:
Replica on successful indexing write its data to translog and sends back success response with same request Id to primary. Lets say I indexed 5 docs successfully on primary but two of them (doc 1 and doc 2) failed to write on replica for some reason, So when commit operation is performed on primary shard, how does it keep track that only doc 3 ,4 and 5 has to be committed and not doc 1 and 2 .
can you please explain me how the above scenario is handled and point me to elasticsearch code base where primary shards is receiving response from replica.


When that happens, a replica shard that missed a write is failed and a new copy is peer recovered from the primary. The code you're looking for starts in TransportReplicationAction that I mentioned previously.

Thanks !!