I am currently implementing a search for people names in a database. It's a structured document that has 3 fields: firstName, middleName, lastName. I started using the cross_fields multi_match query and it works fine unless one corner case. This is the query that I run:
"multi_match": {
"fields": [
"name.firstName^2",
"name.middleName",
"name.lastName^3"
],
"query": "John Smith",
"operator": "AND",
"type": "cross_fields"
}
I would like the object to be treated as one single long field, but boosted in the order lastName, firstName. The problem is that the following documents get the same score:
{
"firstName": "John",
"lastName": "Smith"
}
and
{
"firstName": "John",
"middleName": "Adams",
"lastName": "Smith"
}
while if you consider length of a "concatenated" field, the first one is 2/2 match and the second is 2/3 match, so 2/2 should be scored higher.
In other words, I would like to perform length normalization in all fields in the multi_match query, not per-field normalization.
Could you advise me how to achieve this?
Thanks!