Combine two fields in search

Hey,

I have the JSON data in elasticsearch as

{
  "prefix": "+46",
  "number":"123456789"
}

So this is a phone number, together with the country code prefix.

And searching for them as separate

prefix: +46
number: 123456789

is very easy, but I want to have one string to be able to match it like

phoneNumber: +46123456789

Since this search doesn't know how long the prefix it, I would like to combine the two fields somehow.

And I dont want to edit all the existing data to add a field that contains the two of them combined.

Is there any smart way I can solve this?

Edit:
Running elasticsearch 7.6.2

A few options;

1 Like