# Problems highlighting with bool + filter query and PHP API

**URL:** <https://discuss.elastic.co/t/problems-highlighting-with-bool-filter-query-and-php-api/61898>\
**Category:** Elasticsearch\
**Created:** [September 30, 2016, 7:07am UTC](https://discuss.elastic.co/t/problems-highlighting-with-bool-filter-query-and-php-api/61898 "2016-09-30T07:07:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joha/32/12235_2.png) [@joha](https://discuss.elastic.co/u/joha)\
**Post date:** [September 30, 2016, 7:07am UTC](https://discuss.elastic.co/t/problems-highlighting-with-bool-filter-query-and-php-api/61898/1 "2016-09-30T07:07:19Z")

</div>

Hi everyone,

I am having problems with highlighting in the PHP API. We are running on ES 1.7.  
If a use a `bool` query for the search it does not return any highlighted results. The search itself works fine. However if a use a simple `match_phrase` query the highlighting works.  
Here is a sample code of the search body:

```auto
$params = [
    'index' => $index,
    'type' => $type,
    'body' => [
        'from' => ( (int)$offset * $this->getSearchResultSize() ),
        'size' => $this->getSearchResultSize(),
        'indices_boost'	=> $this->getIndicesBoosts(),
        'sort' => $this->getSorting(),
        'query' => [
            'bool' => [
                 'must' => [
                     'term' => ['_all' => $query],
                     'filter'	=> $this->getFilterConditions( $acl, $product, $spaceId )
                 ]
             ]
        ],
        'highlight' => [
            'pre_tags' => ['<span class="search-highlight">'],
            'post_tags' => ['</span>'],
            'fields' => [
                'content' => [
                    'force_source' => true,
                    'fragment_size' => 100,
                    'number_of_fragments' => 3
                ]
            ],
        ]
    ]
];

```

If i replace the bool query with

```auto
'match_phrase'	=> [
    'content' => $query
 ]

```

it works.

I already tried using the same query as in the search as `highlight_query` but that did not help either. Casting the `fields` array to an object also did not help.

Is there any way I can get the highlighting work with the bool query?

EDIT: The same applies for aggregations.

Thanks for your help!

Joe

---

<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, 10:15pm UTC](https://discuss.elastic.co/t/problems-highlighting-with-bool-filter-query-and-php-api/61898/2 "2017-07-05T22:15:48Z")

</div>


