`highlight_query.query_string` still drops quoted expressions — the #4115 fix did not reach the JSON path

Author: ArturusCreated Sep 16, 2026Updated Sep 16, 2026

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 highlighthighlight_queryquery_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_query is the same as for the main query. — Searching/Highlighting.md

Reproduce

bash
docker run --rm -d --name mant -p 19308:9308 manticoresearch/manticore:latest
bash
curl -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

bash
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":[""]}'
json
{"hits":{"total":1,"hits":[{"_id":1,"_score":2500,"_source":{}}]}}

2. The same phrase as highlight_query.query_string — empty block

bash
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}}'
json
{"hits":{"hits":[{"_id":1,"_source":{},"highlight":{}}]}}

3. The same words unquoted — highlighted

bash
... "highlight_query":{"query_string":"hello world"} ...
json
"highlight":{"content":["a <b>hello world</b> example"]}

4. match_phrase form of the same phrase — highlighted

bash
... "highlight_query":{"match_phrase":{"content":"hello world"}} ...
json
"highlight":{"content":["a <b>hello world</b> example"]}

5. SQL HIGHLIGHT() with the same quoted phrase — highlighted

bash
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')"
json
{"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