# Does flush method works in ES php api?

**URL:** <https://discuss.elastic.co/t/does-flush-method-works-in-es-php-api/26417>\
**Category:** Elasticsearch\
**Created:** [July 28, 2015, 2:08pm UTC](https://discuss.elastic.co/t/does-flush-method-works-in-es-php-api/26417 "2015-07-28T14:08:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rabeetwaqar](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@rabeetwaqar](https://discuss.elastic.co/u/rabeetwaqar)\
**Post date:** [July 28, 2015, 2:08pm UTC](https://discuss.elastic.co/t/does-flush-method-works-in-es-php-api/26417/1 "2015-07-28T14:08:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [August 19, 2015, 7:39pm UTC](https://discuss.elastic.co/t/does-flush-method-works-in-es-php-api/26417/2 "2015-08-19T19:39:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rabeetwaqar](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@rabeetwaqar](https://discuss.elastic.co/u/rabeetwaqar)\
**Post date:** [August 21, 2015, 11:24am UTC](https://discuss.elastic.co/t/does-flush-method-works-in-es-php-api/26417/3 "2015-08-21T11:24:46Z")

</div>

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

Yeah sure , will follow you up there 😄

Thanks

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [August 21, 2015, 11:27am UTC](https://discuss.elastic.co/t/does-flush-method-works-in-es-php-api/26417/4 "2015-08-21T11:27:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rabeetwaqar](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@rabeetwaqar](https://discuss.elastic.co/u/rabeetwaqar)\
**Post date:** [August 21, 2015, 11:33am UTC](https://discuss.elastic.co/t/does-flush-method-works-in-es-php-api/26417/5 "2015-08-21T11:33:42Z")

</div>

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 😉 i know its not a good way to do this but will see flush method when i will have extra pair of time. 😉

Thanks

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [August 21, 2015, 11:49am UTC](https://discuss.elastic.co/t/does-flush-method-works-in-es-php-api/26417/6 "2015-08-21T11:49:16Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![rabeetwaqar](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@rabeetwaqar](https://discuss.elastic.co/u/rabeetwaqar)\
**Post date:** [August 21, 2015, 11:53am UTC](https://discuss.elastic.co/t/does-flush-method-works-in-es-php-api/26417/7 "2015-08-21T11:53:02Z")

</div>

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:54pm UTC](https://discuss.elastic.co/t/does-flush-method-works-in-es-php-api/26417/8 "2017-07-05T23:54:36Z")

</div>


