Require Elasticsearch highlight words enclosed with Double Quotes (") instead of chopping them

Elasticsearch: v7.2
Application: PHP - Laravel v5.7

Hello and good day!

I'm developing a web application that is similar to a search engine, whereas a user will enter words that will be designated to the variable $keywords . Then I have this query to search throughout my index:

$params = [
    'index' => 'my_index',
    'type'  => 'my_type',
    'from'  => 0,
    'size'  => 10,
    'body'  => [
        "query" => [
            'bool' => [
                'must' => [
                        "query_string" => [
                            "fields" => ['title','content'],
                            "query" => $keywords

$articles = $client->search($params);

Now, in line with my previous post, I was able to count the number of occurrences my $keywords occurred within the documents of my index.

Here's my highlight query that is attached to the $params above:

"highlight" => [
    "fields" => [
        "content" => ["number_of_fragments" => 0],
        "title" => ["number_of_fragments" => 0]
    'require_field_match' => true

Even though that the $keywords are enclosed with double quotation mark ("), the highlighter still chops/separates the $keywords and I already specified them with double quotation mark to strictly follow these words .

For example, my $keywords contains "Ayala Alabang" , but as I displayed the output, it goes like this

The $keywords were separated, but according to the output, they're just adjacent to each other.

Is there any other tweaks or revision to my query? I found some related posts or questions in some forums, their last reply was from March 2019 but still no answers, any advice would be an greatly appreciated and an excellent help for this dilemma

We have a number of different highlighters available which is a reflection of how many different people have attempted to tackle this tricky problem over the years.
Some highlighter implementations are faster, some are better at highlighting phrases (your problem) than others. It's worth experimenting to see which offers the best trade off.

Hello sir @Mark_Harwood, thank you very much for your insight, appreciate it!

As for my problem, after several days of experimenting, I found the Elasticsearch search feature called explain. So I utilized that feature and was able to come up a solution that no longer requires highlights (coz it really gave me a hard time solving it BIG TIME)

Here's my thorough answer:

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