nick-boss-tech opened a new pull request, #5104:
URL: https://github.com/apache/solr/pull/5104

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-2681
   
   ## What happens today
   
   **With the original highlighter, a query wrapped in a function query is not 
highlighted.**
   
   Take `q={!func}query($v1)` with `v1={!dismax qf=t_text}lorem`, `hl=true`, 
`hl.fl=t_text`, and `hl.method=original`. The document has `t_text` set to 
`lorem ipsum`, and `lorem` is not wrapped in `<em>` tags. The base term 
extractor has no case for `FunctionQuery`, so it never reads the query inside 
it ([base 
code](https://github.com/nick-boss-tech/solr/blob/cabedd1d968059215188f4e7563fb303241899ed/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java#L295-L298)).
   
   ## What this change does
   
   **The original highlighter now reads the query inside a `query(...)` 
function query.**
   
   When the top-level query is a function query whose value source is a 
`query(...)` call, the term extractor collects terms from the wrapped query 
([code](https://github.com/nick-boss-tech/solr/blob/a3b1ea7994d932cdf78667f799542d7d823f7d49/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java#L300-L303)).
 All other queries take the same path as before. The change is in the original 
highlighter's term extractor only.
   
   Behavior change: a request whose top-level query is `query(...)` now 
highlights the wrapped query's terms in the requested fields. Before this 
change, those terms were not highlighted.
   
   ## Proof
   
   **The new test fails on the base code and passes with this change.**
   
   - `HighlighterTest.testHighlightQueryInsideFunctionQuery` 
([test](https://github.com/nick-boss-tech/solr/blob/a3b1ea7994d932cdf78667f799542d7d823f7d49/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java#L91-L109)).
 On the base code, with only the new test added, HighlighterTest runs 36 tests 
and one fails: this test.
   - At head `a3b1ea7994d`, HighlighterTest passes 36 of 36.
   
   The test uses `hl.method=original` and covers only the top-level 
`query(...)` form.
   
   ## Limits
   
   **Only a `query(...)` call at the top of a function query is handled.**
   
   - The ticket's example, `{!func}product($v1,$v2)`, nests the query inside 
another function. The change does not reach that form, and no test covers it.
   - Other value sources that wrap a query are not handled. A follow-up 
submission is planned for the nested forms.
   - The FastVector highlighter is not changed and not tested.
   
   Changelog: `changelog/unreleased/SOLR-2681-highlight-function-query.yml`
   
   ### AI assistance
   
   AI agents assisted with research, implementation, review, and drafting. Nick 
Shanin directed the work and takes responsibility for this contribution.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to