Php Elastica \ Exception \ ResponseException,消息NoShardAvailableActionException [[index] [0] null]

I am using php elastica client (https://github.com/ruflin/Elastica) for adding documents in elasticsearch index.

What happens is, the first time I try to add a document, I get this error:

'Elastica\Exception\ResponseException' with message
'NoShardAvailableActionException[[index][0] null]; nested: IllegalIndexShardStateException[[index][0] CurrentState[RECOVERING] operations only allowed when started/relocated

The document does not get added to the index but its mapping is created.

After this, it just works fine, the document gets added to the index. Maybe (rather surely) I am doing something wrong. Please help me fix this issue.

Here is my yaml configuration:

indexes:
    myIndex:
        client: default
        types:
            myType:
                mappings:
                    id: {type: integer, index: not_analyzed}
                    name: {type: string, index: not_analyzed}
                    location: {type: geo_point}

And here is how I am adding a document:

$doc = new \Elastica\Document();
$doc->setData($arrDoc);
$doc->setId($id); 
$objType->addDocument($doc); //object of \Elastica\Type