Is there a way to match multi-fields but always highlight the base field?

Say I have the following mappings:

"phone": {
    "type": "keyword",
    "fields": {
        "digits": {
            "type": "keyword",
            "analyzer": "digit_only"
        }
    }
}

The analyzers are using simple_pattern tokenizer to capture any phone or email in the contact string. A sample data looks like "phone": "(01)23456-789", which will be indexed with the original string and phone 0123456789 (extracted by the regex in tokenizer).

What I want to achieve is no matter how the user issue variations of equivalent numbers, the phone is matched and the original string is returned in highlight value.

At the moment, I managed to get the matched results back by issuing a boolean query one for the phone field and one for the phone.digits field, however, the highlight sometimes highlights phone (when user inputs exactly the original string) or highlights phone.digits (when user inputs just numbers).

Is there a way to always highlight the phone field no matter the match is on phone or phone.digits?

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