nick-boss-tech opened a new pull request, #5183: URL: https://github.com/apache/solr/pull/5183
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)* https://issues.apache.org/jira/browse/SOLR-18555 ## What happens today **Solr's existing highlighting component expects search results, so it cannot highlight a supplied text body by itself.** The component asks the search pipeline for a `DocList` before adding highlights. This ticket requests highlighting text supplied directly in a request, without searching documents. [Base implementation](https://github.com/apache/solr/blob/c8ab71430f6e7547c773da596101d680862310ff/solr/core/src/java/org/apache/solr/handler/component/HighlightComponent.java#L96-L100). ## What this change does **A new `/highlight` handler applies query highlighting to supplied text without acquiring a searcher.** It accepts one `text/plain` stream or a `GET` request with `stream.body`, uses Lucene's UnifiedHighlighter with the whole input as one passage, and returns snippets under `highlighting.text.<field>`. Legacy and V2 routes support `GET`, `POST`, and `QUERY`. The handler uses the built-in Lucene parser and rejects parser overrides, local-parameter parser syntax, and `_query_` subqueries. The default input limit is 51,200 characters and the maximum is 1,048,576. [Handler](https://github.com/nick-boss-tech/solr/blob/884de51579dc39a196292bbf7184b6aa2601099b/solr/core/src/java/org/apache/solr/handler/HighlightRequestHandler.java#L83-L159) [input and parser bounds](https://github.com/nick-boss-tech/solr/blob/884de51579dc39a196292bbf7184b6aa2601099b/solr/core/src/java/org/apache/solr/handler/HighlightRequestHandler.java#L166-L234) [parser restrictions](https://github.com/nick-boss-tech/solr/blob/884de51579dc39a196292bbf7184b6aa2601099b/solr/core/src/java/org/apache/solr/handler/HighlightRe questHandler.java#L285-L310) [HTTP coverage](https://github.com/nick-boss-tech/solr/blob/884de51579dc39a196292bbf7184b6aa2601099b/solr/core/src/test/org/apache/solr/handler/HighlightRequestHandlerHttpTest.java#L50-L105). ## Proof **Focused tests are queued, and their results are pending.** `HighlightRequestHandlerTest` covers response shape, encoding, query forms, input bounds, invalid input, parser restrictions, permission, and the no-searcher path. `HighlightRequestHandlerHttpTest` covers the legacy and V2 routes. Neither class has been run yet; there are no pass counts to report. The pending queue job enables Spotless and fail-before proof at head `884de51579dc39a196292bbf7184b6aa2601099b`. [Unit tests](https://github.com/nick-boss-tech/solr/blob/884de51579dc39a196292bbf7184b6aa2601099b/solr/core/src/test/org/apache/solr/handler/HighlightRequestHandlerTest.java#L47-L319) [HTTP tests](https://github.com/nick-boss-tech/solr/blob/884de51579dc39a196292bbf7184b6aa2601099b/solr/core/src/test/org/apache/solr/handler/HighlightRequestHandlerHttpTest.java#L50-L105). ## A choice to check **I kept the input contract to raw text instead of routing document formats through the update handler.** This avoids document update processing and keeps the handler focused on text supplied for highlighting. Would you prefer this `text/plain` contract, or should the handler accept Solr document formats too? I can expand this PR if maintainers prefer the broader input contract. ## Limits **This handler covers supplied text, not indexed documents or structured update payloads.** It rejects wildcard fields and does not support parser plugins. Schema field types and analyzers remain configured Solr extensions. The default `simple` encoder does not escape HTML; the guide recommends `hl.encoder=html` for HTML output and says custom tags must be trusted. [Handler limits](https://github.com/nick-boss-tech/solr/blob/884de51579dc39a196292bbf7184b6aa2601099b/solr/core/src/java/org/apache/solr/handler/HighlightRequestHandler.java#L214-L234) [guide](https://github.com/nick-boss-tech/solr/blob/884de51579dc39a196292bbf7184b6aa2601099b/solr/solr-ref-guide/modules/query-guide/pages/highlighting.adoc#L26-L67). Changelog: [SOLR-18555.yml](https://github.com/nick-boss-tech/solr/blob/884de51579dc39a196292bbf7184b6aa2601099b/changelog/unreleased/SOLR-18555.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]
