Skip to content

SOLR-18555: Add a handler for highlighting supplied text - #5183

Closed
nick-boss-tech wants to merge 12 commits into
apache:mainfrom
nick-boss-tech:solr-18555-submit
Closed

nick-boss-tech wants to merge 12 commits into
apache:mainfrom
nick-boss-tech:solr-18555-submit

Conversation

@nick-boss-tech

@nick-boss-tech nick-boss-tech commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖 (posted on behalf of Nick Shanin)

https://issues.apache.org/jira/browse/SOLR-18555

What happens today

HighlightComponent needs a search result to create snippets. It requests a DocList before highlighting, so text in a request body alone is not enough. Base implementation

What this change does

The new /highlight handler highlights one supplied text value without opening a searcher. _default registers it. POST accepts a text/plain body; GET uses stream.body. Routes are /solr/{collection}/highlight, /api/c/{collection}/highlight, and /api/cores/{core}/highlight. Snippets appear under highlighting.text.<field>. Handler and routes Config

Query parsing uses built-in Lucene syntax. Parser overrides, local parameters, and subqueries are disabled; wildcard fields are rejected. _default uses _text_ as df. hl.maxAnalyzedChars defaults to 51,200, is capped at 1,048,576, and truncates longer input. The V2 spec allows GET and POST. This PR leaves the shared SolrJ method enum unchanged, and HTTP tests reject QUERY on update and highlight routes. Query restrictions HTTP tests

Proof

Phase r1 passed at head b99259cba3572cc08586b2456c78780c814a2bf7 on 2026-10-19: HighlightRequestHandlerTest passed 10 tests, HighlightRequestHandlerHttpTest passed 2, and :solr:core:check -x test passed. The base fails the new handler test with a LinkageError because the handler is absent. Phase r1 receipt

At current head 2c54781a6ea1c8a5d17b802fbc97fed18005aa2b, phase r2 was handed back after testGetStreamBodyAndV2Routes failed: GET on /c/<core>/highlight returned HTTP 500 in the non-cloud fixture because collection aliases require ZooKeeper there. The gate produced no proof for this head. Phase r2 result HTTP test at current head

A choice to check

GET/POST and the simple encoder are the current defaults. Should the handler also accept body-oriented QUERY? That requires a shared SolrJ enum change and broader V2 method parsing, with authorization and client support to review. It remains outside this PR's scope.

The simple encoder leaves text unescaped. Should this handler default to html for snippets rendered as HTML? That changes the response, while callers can already set hl.encoder=html. Encoder and guide

Limits

Input past hl.maxAnalyzedChars is omitted without a signal, hl.fl has no separate field-count cap, and _query_ rejection reports undefined field _query_. These can be handled as focused follow-ups if maintainers want them. Input and field handling

Changelog: changelog/unreleased/SOLR-18555.yml

AI-generated description. Nick Shanin directed the work and takes responsibility for this contribution.

@github-actions github-actions Bot added documentation Improvements or additions to documentation configs client:solrj tests labels Oct 19, 2026
@nick-boss-tech

Copy link
Copy Markdown
Contributor Author

Still working on this and will resubmit soon, I am considering splitting it into 2 PRs since the first one can be narrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configs documentation Improvements or additions to documentation tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant