`highlight_query.query_string` still drops quoted expressions — the #4115 fix did not reach the JSON path
Bug description
#4115 reported
that HIGHLIGHT() highlights nothing when its query is a quoted expression, and
was closed 2026-01-14 by
ee9eaf5,
with the note "now snippet generation \ HIGHLIGHT use the same query transform as
it uses for search."
That holds for SQL. It does not hold for highlight_query in a JSON /search
request, which still returns an empty highlight block. Running #4115's own
reproducer on 29.9.0:
| query | SQL HIGHLIGHT() |
JSON highlight_query.query_string |
|---|---|---|
(happy | sad | angry) customer |
<b>happy customer</b> |
<b>happy customer</b> |
"(happy | sad | angry) customer" |
<b>happy customer</b> |
"highlight": {} |
The same is true of an ordinary quoted phrase, which is how we hit it.
In a JSON /search request, a quoted phrase inside
highlight → highlight_query → query_string produces "highlight": {} — no
error, no markup — on a document the phrase matches. The same phrase works as the
main query, as highlight_query.match_phrase, and in SQL HIGHLIGHT().
Worse, one quoted phrase empties the block for every other arm of the same
highlight query. On a 71M-document table, five documents drawn by mocktail:
highlight_query.query_string |
documents highlighted |
|---|---|
mocktail |
5 of 5 |
mocktail | "non-alcoholic" |
0 of 5 |
The manual states the contract this breaks:
The syntax for
highlight_queryis the same as for the mainquery. — Searching/Highlighting.md
Reproduce
docker run --rm -d --name mant -p 19308:9308 manticoresearch/manticore:latestcurl -s 'http://127.0.0.1:19308/sql?mode=raw' --data-urlencode "query=CREATE TABLE t (content text)"
curl -s 'http://127.0.0.1:19308/sql?mode=raw' --data-urlencode "query=INSERT INTO t (id, content) VALUES (1, 'a hello world example')"1. The phrase as the main query — matches
curl -s http://127.0.0.1:19308/search -H 'Content-Type: application/json' -d '
{"table":"t","query":{"query_string":"\"hello world\""},"limit":1,"_source":[""]}'{"hits":{"total":1,"hits":[{"_id":1,"_score":2500,"_source":{}}]}}2. The same phrase as highlight_query.query_string — empty block
curl -s http://127.0.0.1:19308/search -H 'Content-Type: application/json' -d '
{"table":"t","query":{"query_string":"hello"},"limit":1,"_source":[""],
"highlight":{"fields":["content"],"highlight_query":{"query_string":"\"hello world\""},"allow_empty":true}}'{"hits":{"hits":[{"_id":1,"_source":{},"highlight":{}}]}}3. The same words unquoted — highlighted
... "highlight_query":{"query_string":"hello world"} ..."highlight":{"content":["a <b>hello world</b> example"]}4. match_phrase form of the same phrase — highlighted
... "highlight_query":{"match_phrase":{"content":"hello world"}} ..."highlight":{"content":["a <b>hello world</b> example"]}5. SQL HIGHLIGHT() with the same quoted phrase — highlighted
curl -s 'http://127.0.0.1:19308/sql?mode=raw' --data-urlencode "query=SELECT HIGHLIGHT({allow_empty=1},'content','\"hello world\"') AS h FROM t WHERE MATCH('hello')"{"h":"a <b>hello world</b> example"}So the fault is specific to a quoted phrase in the query_string spelling of
highlight_query. match_phrase and SQL both handle it.
Expected
Step 2 returns the same passage as steps 3, 4 and 5.
Related
- #4115 — same symptom via SQL, fixed. This is the JSON half.
- #1077,
#1412 — blend
chars not highlighted via SQL. Both still open, and different: our
"non-alcoholic"does highlight correctly through SQL on 29.9.0.
Why this one is worth fixing even though a workaround exists
It fails silently. allow_empty makes an empty block legitimate, so a caller
cannot tell "the phrase did not match here" from "the phrase was dropped". Our
phrase arms sampled blank for months before anyone noticed, and match_phrase is
not a substitute where the highlight query is an arbitrary boolean expression.
Manticore Search version
28.6.6 e5feb9932@26073104 and 29.9.0 58e88d5ab@26091108. Identical behaviour on
both.
Operating system version
Docker on Ubuntu (WSL2, kernel 6.6.87.2), image manticoresearch/manticore.
Have you tried the latest development version?
Yes — reproduces unchanged on manticoresearch/manticore:latest, 29.9.0.
How does this bug affect you?
Annoying, but I found a workaround. We spell every phrase as its words before sending the highlight query, which widens the passage window but keeps the block populated.
Source: manticoresoftware/manticoresearch