I am trying to search for a multi-word phrase using regular expressions. I would prefer to use the FVH because the unified highlighter tends to break highlighting chunks between the words within a phrase. So I would prefer to use a query_string query instead of a span_multi query. A phrase search with query_string without regular expressions functions as expected. So
{
"query": {
"query_string": {
"query": "\"präsentierten Belege\"", "fields": ["text"]
}
}, "highlight": {"fields": {"text": {"type": "fvh"}}}
}
returns only documents where the words "präsentierten" and "Belege" occur directly next to each other. But when I try to use regular expressions, like this
{
"query": {
"query_string": {
"query": "/präsentier.*/ /Beleg.*/", "fields": ["text"]
}
}, "highlight": {"fields": {"text": {"type": "fvh"}}}
}
I get texts that have either a word starting with "präsentier" or with "Beleg" but not necessarily with both in the same document. If I put AND between the terms then I only get documents with both words but not necessarily in a phrase right next to each other. If I enclose the whole search query with quotation marks, like so:
{
"query": {
"query_string": {
"query": "\"/präsentier.*/ /Beleg.*/\"", "fields": ["text"]
}
}, "highlight": {"fields": {"text": {"type": "fvh"}}}
}
then I get no results even though the phrase "präsentierten Belege" exists in the documents and thus should be matched.
Is this possible without using a span query? If so, how?