Update dependency org.apache.tika:tika-core to v4 - #4853
Conversation
|
Seems early enough that we can move to tika 4? |
|
Commonmark for Markdown parsing is now part of tika-core. Our extraction handler currently does not rely on MD, but explicitly requests xml from tika-server. So we could attempt excluding these three new jar deps and see if it will fly. There may be some part of core depending on these classes even if we don't use them explicitly so maybe not worth the risk? |
|
@tballison somebody moved my cheese ;-). |
Edited/Blocked NotificationRenovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR. You can manually request rebase by checking the rebase/retry box above. |
…xml. This is mostly a "hey, look, I got us to tika 4", but it feels like its still trying to push Tika 4 into a tika 3 approach, when Tika wants to be different.
I'd say we stay on 3.x for Solr 10, and work on exploring how to best utilize Tika 4 on main only, i.e. no backport. to 10.x. Of course, if we get to a stable back-compat impl of Tika 4 on main, it can be back-ported without risk. Even if Tika gains features like AI stuff, we are not obliged to use those :-) |
|
On phone with @epugh now, lol. Let me know if I can help, or if I've done enough damage. 🤣 |
|
Umm... at least locally the bats test and unit tests passed!!! So maybe this isn't the lift I thought it was? |
That works for me... As @tballison pointed out, it's literally a |
There was a problem hiding this comment.
🟡 Changes recommended
License validation will fail on a stale checksum, while error and partial-extraction handling can produce incorrect request outcomes.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Upgrades Solr Cell to Tika 4 and adapts its server integration to Tika’s new endpoints, metadata keys, and per-request configuration.
Changes:
- Updates Tika and Docker images to 4.0.0, including dependencies and licenses.
- Adds multipart parser configuration and password handling.
- Updates extraction tests and documentation for Tika 4 behavior.
File summaries
| File | Description |
|---|---|
gradle/libs.versions.toml |
Updates Tika to 4.0.0. |
solr/modules/extraction/gradle.lockfile |
Locks Tika and CommonMark dependencies. |
TikaServerExtractionBackend.java |
Implements Tika 4 request and response handling. |
TikaServerParser.java |
Supports renamed recursive metadata content keys. |
ExtractionRequest.java |
Adds per-request Tika configuration. |
ExtractingParams.java |
Defines the new configuration parameter. |
ExtractingDocumentLoader.java |
Passes configuration from request parameters. |
TikaServerExtractionBackendTest.java |
Tests configuration, passwords, and Tika 4 behavior. |
TikaServerContainerRule.java |
Runs the Tika 4 container with optional configuration. |
ExtractingRequestHandlerTikaServerTest.java |
Enables per-request configuration in integration tests. |
ExtractingRequestHandlerTestAbstract.java |
Updates expected Tika metadata keys. |
tika-server-config.json |
Enables test-time per-request configuration. |
test_extraction.bats |
Updates the packaging test container. |
indexing-with-tika.adoc |
Documents Tika 4 and parser configuration. |
tutorial-diy.adoc |
Updates the tutorial container version. |
tika-core-4.0.0.jar.sha1 |
Adds the Tika checksum. |
commonmark-LICENSE-BSD.txt |
Adds the CommonMark license. |
commonmark-NOTICE.txt |
Adds the CommonMark notice file. |
commonmark-0.30.0.jar.sha1 |
Adds the CommonMark checksum. |
commonmark-ext-gfm-tables-0.30.0.jar.sha1 |
Adds the tables extension checksum. |
commonmark-ext-gfm-strikethrough-0.30.0.jar.sha1 |
Adds the strikethrough extension checksum. |
PR#4853-update-org-apache-tika-tika-core.yml |
Records the dependency update. |
Review details
- Files reviewed: 21/22 changed files
- Comments generated: 5
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @@ -0,0 +1 @@ | |||
| f370d8619de9e19329b2cc117943c83468c2ff9f | |||
| if (code == 422 && !request.tikaServerRecursive) { | ||
| PushbackInputStream peekable = new PushbackInputStream(responseStream, 1); | ||
| int firstByte = peekable.read(); | ||
| if (firstByte == -1) { | ||
| throw new SolrException( |
| .tikaServerRecursive(tikaserverRecursive) | ||
| .tikaServerTimeoutSeconds(tikaTimeoutSecs) | ||
| .tikaServerRequestHeaders(Map.of()) | ||
| .tikaServerConfigJson(params.get(ExtractingParams.TIKASERVER_CONFIG_JSON)) |
| * have {@code allowPerRequestConfig=true} set, or the request is rejected with 403. Ignored for | ||
| * recursive (tikaserver.recursive) requests, since TikaServer has no XML-output variant of | ||
| * /rmeta/config. |
| // Tika 4.x renamed its metadata keys under a single lowercase tk: prefix (TIKA-4816) | ||
| "fmap.tk:parsed-by", | ||
| "ignored_parser", | ||
| "fmap.X-TIKA:Parsed-By", | ||
| "fmap.tk:parsed-by-full-set", | ||
| "ignored_parser", |
| // that). A request that extracted nothing at all (e.g. a wrong password) also gets 422, but | ||
| // with an empty body -- treat that case as the failure it is instead of a silent empty | ||
| // "success". Peek the first byte to tell the two apart. | ||
| if (code == 422 && !request.tikaServerRecursive) { |
There was a problem hiding this comment.
We moved to default single file per-fork processing. We now have 429 as a backpressure signal, if a request can't find an active worker in 30s(?), you'll get 429.
|
|
||
| [IMPORTANT] | ||
| ==== | ||
| `tikaserver.config` requires your Tika Server to be started with `allowPerRequestConfig: true` in its own JSON configuration (under the `server` section). |
There was a problem hiding this comment.
This sentence by itself suggests that you have to have this. I'd recommend editing so there's an "if you want per file config, you'll need this". Ignore this comment if tikaserver.config is saying exactly that. :/
| ==== | ||
|
|
||
| NOTE: In earlier versions of Solr Cell you could supply Tika configuration directly to Solr. This is no longer possible. | ||
| `tikaserver.config` is combined with any password resolved from `resource.password` or `passwordsFile` (see <<Indexing Encrypted Documents>>) into a single request to Tika Server, and is only supported for non-recursive extraction (`tikaserver.recursive=false`, the default); Tika Server has no way to accept per-request configuration for recursive extraction while also returning the XHTML content Solr Cell needs. |
There was a problem hiding this comment.
POST /rmeta/config
part "file": <document>
part "config": {"basic-content-handler-factory":{"type":"XML"},
"pdf-parser":{"ocr":{"strategy":"NO_OCR"}},
"simple-password-provider":{"password":"..."}}
should work. This is less than ideal. My gut says that we should go with symmetry between /rmeta/config/xml and /tika/config/xml; but I now remember why we chose this path. I need to chat with the team to figure out whether to fix this for 4.1.0. Apologies for the noise.
There was a problem hiding this comment.
| assertTrue(c.contains("embedded:image0.jpg")); | ||
| assertEquals( | ||
| "org.apache.tika.parser.DefaultParser", md.getFirst("X-TIKA:Parsed-By-Full-Set")); | ||
| // Tika 4.x renamed its metadata keys under a single lowercase tk: prefix (TIKA-4816) |
There was a problem hiding this comment.
these 🤖 comments are useful for PR review, but there's no need for history, is there?
| A raw JSON object sent as the per-request parser configuration for Tika Server (e.g., `{"pdf-parser":{"ocr":{"strategy":"NO_OCR"}}}`). | ||
| See <<Parser-Specific Properties>> below for details and an important security note: this requires `allowPerRequestConfig=true` on the Tika Server, which is off by default. | ||
| + | ||
| Example: `tikaserver.config={"pdf-parser":{"ocr":{"strategy":"NO_OCR"}}}` |
There was a problem hiding this comment.
What triggered you to enable this? Can we not just tell users to configure their Tika Server?
I view extraction handler as a low-end solution for folks who have very simple extraction needs and just want it embedded in solr. If you hare in the business of really heavy extraction you're probably running a custom Tika cluster on the application side and inject already extracted text in plain solr documents?
There is a cost associated with every additional config we need to document, support, deprecate if tika changes format etc. If you give a real-life example of its utility, something we believe will be truly useful, then I want to hear.
There was a problem hiding this comment.
The above allows fine-grained control over ocr on PDFs. I agree with your point about the user base for the extraction handler.
If you don't want to allow configs or deal with documentation, you can cut it all out.
For the intermediate user, as long as you are loading an initialization config, they can figure this out on their own.
Out of the box, no config, and off you go.
tballison
left a comment
There was a problem hiding this comment.
LGTM. Couple of documentation issues. Fix incoming in 4.1.0.
On documentation, my bot recommends adding:
Sizing / provisioning
https://tika.apache.org/docs/4.0.x/pipes/cpu-sizing.html
The formula: numClients × 2 + 2 ≤ hostCores, and why forks get -XX:ActiveProcessorCount auto-injected.
What numClients actually controls (the one to lead with)
https://tika.apache.org/docs/4.0.x/using-tika/server/index.html#_endpoints_and_forked_process_groups
"Endpoints and Forked-Process Groups" — it does two separate jobs: bounds concurrent requests per group and sizes each fork's CPU view. Also says /tika + /rmeta + /unpack + /meta + /detect + /pipes all share
one group, which matters for Solr since they use /tika/xml and /rmeta/xml.
Backpressure
https://tika.apache.org/docs/4.0.x/using-tika/server/index.html#_backpressure_the_server_can_tell_you_it_is_busy
The 429 + Retry-After contract.
This PR contains the following updates:
3.3.1→4.0.0Release Notes
apache/tika (org.apache.tika:tika-core)
v4.0.0Compare Source
v3.3.2Compare Source
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Renovate Bot