# How to check if results are empty in SearchHitIterator in php

**URL:** <https://discuss.elastic.co/t/how-to-check-if-results-are-empty-in-searchhititerator-in-php/355366>\
**Category:** Elasticsearch\
**Created:** [March 14, 2024, 7:25am UTC](https://discuss.elastic.co/t/how-to-check-if-results-are-empty-in-searchhititerator-in-php/355366 "2024-03-14T07:25:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aditya\_Dixit1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aditya_dixit1/32/124795_2.png) [@Aditya\_Dixit1](https://discuss.elastic.co/u/Aditya_Dixit1)\
**Post date:** [March 14, 2024, 7:25am UTC](https://discuss.elastic.co/t/how-to-check-if-results-are-empty-in-searchhititerator-in-php/355366/1 "2024-03-14T07:25:05Z")

</div>

I am using a `SearchHitIterator` in php like this

```php
$params = [
                'index' => 'empire',
                'body' => [
                    'query' => [
                        'match' => [
                            "entity.$field" => [
                                'query' => $query,
                                'analyzer' => 'my_analyzer'
                            ]
                        ]
                    ]
                ]
            ];
            $pages = new SearchResponseIterator($this->client, $params);
            $hits = new SearchHitIterator($pages);

```

Is there a method to check if results are empty?

---

<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:** [April 11, 2024, 7:25am UTC](https://discuss.elastic.co/t/how-to-check-if-results-are-empty-in-searchhititerator-in-php/355366/2 "2024-04-11T07:25:37Z")

</div>

Closed on April 11, 2024, 7:25am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
