Elasticsearch recovery: try to recover [your-index][X] from primary shard with sync id but number of docs differ

If you have the follwing error, for example after diskspace problems:

[2016-05-13 12:09:41,770][WARN ][indices.cluster          ] [stage-elasticsearch1] [[logstash-2016.05.12.21][1]] marking and sending shard failed due to [failed recovery]
RecoveryFailedException[[logstash-2016.05.12.21][1]: Recovery failed from {stage-elasticsearch2}{5vAIif9rSRi4xthlji1pGQ}{192.168.216.12}{192.168.216.12:9300}{max_local_storage_nodes=1, master=true} into {stage-elasticsearch1}{I6DMfjXiQP61532HqJ77YA}{192.168.217.12}{192.168.217.12:9300}{max_local_storage_nodes=1, master=false}]; nested: RemoteTransportException[[stage-elasticsearch2][192.168.216.12:9300][internal:index/shard/recovery/start_recovery]]; nested: RecoveryEngineException[Phase[1] phase1 failed]; nested: RecoverFilesRecoveryException[Failed to transfer [0] files with total size of [0b]]; nested: IllegalStateException[try to recover [logstash-2016.05.12.21][1] from primary shard with sync id but number of docs differ: 668 (stage-elasticsearch2, primary) vs 669(stage-elasticsearch1)];

You can easily fix this with this command:

curl -XPOST http://localhost:9200/logstash-2016.05.12.21/_flush?force