I have a multi_match
query of type cross_fields
, which I want to improve with prefix matching.
{
"index": "companies",
"size": 25,
"from": 0,
"body": {
"_source": {
"include": [
"name",
"address"
]
},
"query": {
"filtered": {
"query": {
"multi_match": {
"type": "cross_fields",
"query": "Google",
"operator": "and",
"fields": [
"name",
"address"
]
}
}
}
}
}
}
It is matching perfectly on queries such as google mountain view
. The filtered
array is there because I dynamically need to add geo filters.
{
"id": 1,
"name": "Google",
"address": "Mountain View"
}
Now I want to allow prefix matching, without breaking cross_fields
.
Queries such as these should match:
goog
google mount
google mountain vi
mountain view goo
If I change the multi_match.type
to phrase_prefix
, it matches the whole query against a single field, so it matches only against mountain vi
but not against google mountain vi
How do I solve this?