Does flush method works in ES php api?

Hello, @polyfractal
$oES = new ElasticSearchApiManager();
$sEsIndexToBeFlushed = array(
'index' => 'index_name'
);
$flushed = $oES->oClient->indices()->flush($sEsIndexToBeFlushed);

It returns :

{"_shards": {"total": 10,"successful": 5,"failed": 0}}

But it doesn't work.
Does flush method works or not?

Thanks in advance

Hi @rabeetwaqar, sorry for missing this!

The flush method does work, to the best of my knowledge. Why do you think it is not working?

BTW, I tend to keep an eye on the repo more than the forums...so if you need help in the future that's a better way to grab my attention.

Hello,
Because the data is not getting flushed , it remains the same as it is.

Yeah sure , will follow you up there :smile:

Thanks

I think you may be having a different problem. Flushing in Elasticsearch just means the non-committed Lucene segments are committed (fsync'd) to disk. It basically tells Lucene to make buffered in-memory data structures durable on disk. It doesn't affect "searchability" or how data is indexed at all.

Yeah i think i'm having some other issues.
Btw i'm now using deleteByQuery with params :

'query': {
'match_all': {}
}

It deletes all the data :wink: i know its not a good way to do this but will see flush method when i will have extra pair of time. :wink:

Thanks

If you just want to delete all your data in an index, there is a Delete Index api which will be much faster / safer:

$client->indices()->delete([
  'index' => 'my_index'
]);

Thanks