| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
@nddipiazza @tballison what do you think of this design instead? far less fields - ability to roll your own protobuf model in the future. Best of both worlds. Document structure is very markdown-friendly. I'll make the output of this be able to be the input of the grpc OpenNLP grpc server. |
Sorry, something went wrong.
There was a problem hiding this comment.
Reviewed the design overall — the shift from mirroring Tika's metadata taxonomy in protobuf to a small, stable document.proto (208 lines) plus per-parser mapper code is a solid answer to the #2916 feedback. A few things worth addressing before merge:
The only change in tika-e2e-tests/tika-grpc is a 2-line fix in HandlerTypeTest.java:
- String htmlContent = htmlReply.getFieldsMap().get("X-TIKA:content");
+ String htmlContent = htmlReply.getDocument().getMarkdown();(same for the TEXT handler case). This is a compile-fix to keep the pre-existing assertion working against the new API — it only proves document.markdown is non-empty over a real gRPC round-trip for two handler types.
It does not exercise, end-to-end, through the live server:
The other e2e tests (FileSystemFetcherTest, IgniteConfigStoreTest, ExternalTestBase) only ever inspect getFetchKey()/getStatus() on FetchAndParseReply — none of them look at getDocument(), so the bulk-corpus/streaming/ignite e2e paths give zero signal on the new typed contract.
The real proof of correctness for the mapping logic lives entirely in tika-grpc-mapper's unit tests (DocumentBuilderTest, MarkdownBlockTreeBuilderTest, one test class per transformer), which feed fixture-derived Metadata/markdown into DocumentBuilder in-process. That's good for the mapping logic itself, but it bypasses the actual gRPC wire serialization, the live server (TikaGrpcServerImpl), the pipes client, and fetcher plumbing entirely.
Ask: add (or extend HandlerTypeTest) at least one e2e case per format that fetches a real file through the live gRPC server and asserts on document.metadata (a couple of typed fields), document.extra (at least one tagged key), and one document.embedded case (e.g. an Office/PDF file with an embedded image) — not just that markdown is non-empty. Right now this new, larger surface area has no live-server coverage at all.
Nice work on the overall shape of the contract — the main blocker from my read is the e2e coverage gap above.
Sorry, something went wrong.
There was a problem hiding this comment.
Overall this is a solid design and a much better-scoped answer to the #2916 feedback: a small stable 208-line proto, format logic pushed into per-parser Java transformers, and a lossless typed+tagged tail. Requesting changes mainly on test coverage for the new contract, plus a couple of correctness/maintainability issues found while reading the mapper code (see inline comments).
Sorry, something went wrong.
|
@nddipiazza great feedback..
My bad; the e2e suite really was only asserting "markdown is non-empty". Added three live-server cases to HandlerTypeTest:
Two things fell out of writing these:
Note the CI e2e job doesn't currently execute these (the -pl tika-e2e-tests -am verify invocation only builds the aggregator POM and no plugins are provisioned) - that's a pre-existing infra gap, but the suite passes locally against a live server. |
Sorry, something went wrong.
|
Thanks for the review @nddipiazza, all four points addressed:
Also merged latest main (the lombok removal and split-packages changes). Full build plus mapper, grpc, and e2e suites pass locally. |
Sorry, something went wrong.
One Document shape for parsed output instead of a message per source format. Content is a block tree anchored to the markdown block model; the tree is canonical and a flat markdown rendering is returned only when the request asks, so a reply never carries the content twice. Format specifics come from per-parser transformer code, not new wire messages: adding a parser never touches the proto. The typed metadata follows the Dublin Core element set (title, authors, description, keywords, languages, publishers, identifiers, dates, rights), with a tagged tail for the rest: typed where Tika declares a type, string otherwise, never guessed. Status lives in one place, the typed ParseStatus for branching plus the raw pipes result name for diagnostics. SourceOrigin records the SHA-256 of the parsed bytes and ParseStatus the producing Tika version. The shape stays small. What it adds is metadata consumers end up parsing or inferring on their own anyway: provenance, typed fields, and structure that does not need a second parse.
DocumentTextFlattener walks Document.blocks depth-first and emits plain text, recording an exact (block path, char range) anchor for every text-bearing block as it goes, so a consumer that annotates the flat text can project spans back onto blocks without re-parsing anything. Tables linearize row-wise with an anchor per cell; code blocks and raw html are skipped for analysis and reported as skipped paths; blocks are separated by a blank line so sentence boundaries cannot cross blocks. FlattenedText carries the document id, the source digest, and a flattening version, since offsets are only meaningful against the exact flattening that produced them.
Parses bytes the caller already has: no fetcher registration, no client-visible server state, and it works with component management locked down. The parse runs in the same isolated forked worker as FetchAndParse. Runtime config-store writes do not reach the forked worker, so the server bakes an internal file-system fetcher, rooted at a server temp directory, into an augmented copy of its config at construction. The payload is written there under a unique name, parsed, and deleted, and the reply carries the caller's request_id as the fetch key and Document id.
|
I figured I'd explain why and what I'm trying to do. I view tika is a primary input plane and think the gRPC server is where I'd want it to integrate. So a Tika Document shape first, including any revisions you think it needs before it becomes a contract. I would use this as my input. The OpenNLP gRPC server is deliberately following OpenNLP 3.0 as it develops. As features are merged to OpenNLP main, I add the corresponding capabilities to the server. My goal is for the gRPC server to be fully compliant with the OpenNLP 3.0 API when I release it and have the ability to extend it (you can see the OpenVINO and TEI extensions already and they're working prototypes). If Tika adopts this Document contract, I will make it a first-class input to that server. The remaining integration details include flattening the block tree, preserving block-to-text offsets, mapping annotations back to source blocks, and deciding which operations should stream. Those can be worked out after the contract is settled. I can also contribute to the fetching, parsing, and performance work here - which I'd love to do. I want to avoid defining and implementing a second document input format before we settle this boundary. If Tika later chooses a different shape, OpenNLP would have an unused input contract and both projects would carry unnecessary compatibility surface. So I'm curious: Is this Document direction an acceptable shared boundary for Tika output and downstream consumers such as OpenNLP? If not, which parts need to change before it can serve that role? I'm in no rush to get the answer - but I've never had an opportunity explicit about the vision and goal. By agreeing to a model, it can allow both projects to launch with an amazing open source story to tell. The current OpenNLP gRPC work is here: https://github.com/apache/opennlp-sandbox/tree/OPENNLP-1833-grpc-expansion Once we agree on a shape, I can make the OpenNLP server conform to it as the rest of the 3.0 features land. This is not going to happen right away - we're still going to tease more releases so I'd expect both servers to go through many iterations. What I'm trying to do on our side is to have a generic enough output shape so we can survive a lot of new features for point releases. With Tika - I want to help integrate and transform a lot of parsing surfaces and connectors (as you saw with the markdown parser). But it all starts with a document shape - then there's no rush to add on more features. Thoughts? |
Sorry, something went wrong.
|
@nddipiazza up for another look? If you land this shape, I can demo how this would work w/opennlp 3's grpc server + make an enhancement to tika to integrate it directly. Let me know what you think - Another suggestion is to make this a separate build under the tika umbrella since you'll need to keep up with CVEs and stuff for creating a docker image. I'd help regardless. Up to you.. |
Sorry, something went wrong.
|
Follow-up after digging further into the tika-grpc/tika-grpc-api contract specifically (cc @tballison since this bears directly on your #2916 feedback). Two scope concerns in the current diff1. ParseBytesRequest/ParseBytes RPC is new scope, not described anywhere in this PR. tika.proto adds a whole new RPC (rpc ParseBytes(ParseBytesRequest) returns (FetchAndParseReply)) for parsing inline bytes without registering a fetcher. It isn't mentioned in the PR description, the "what's in / deliberately not in this PR" table, or the client migration table — it has nothing to do with the typed Document contract. The implementation in TikaGrpcServerImpl is also a real workaround, not a thin RPC:
Given the whole point of this PR (and #2916) is keeping tika-grpc small and reviewable, I'd pull ParseBytes into its own PR/JIRA with its own review. 2. FormatCategory re-bakes per-format buckets into the wire contract. document.proto's FormatCategory enum (PDF/OFFICE/IMAGE/HTML/RTF/EPUB/WARC/GENERIC) plus its detector (FormatCategoryDetector, mime/extension string matching) reintroduces the pattern called out in #2916 point 3 — re-deriving something Tika already told us (content_type already carries the detected MIME type) via a hand-maintained second classification. Every new "coarse category" is a public proto enum change — the same wire churn this PR's premise is meant to avoid. RTF/EPUB/WARC already getting dedicated enum values shows the pull. The docs pitch "adding a format = adding a DocumentTransformer, wire contract doesn't move" isn't quite true here. Aside from those two, the actual mapper transformers (PdfDocumentTransformer, OfficeDocumentTransformer, EpubDocumentTransformer, WarcDocumentTransformer, etc.) are appropriately thin now — 40-70 lines each, no format-structure-extraction logic living in tika-grpc-mapper — and the module's main-scope deps are clean (tika-core + tika-grpc-api + commonmark + protobuf-java; every parser module is test-scoped only). That part of the #2916 "wrong altitude" concern looks resolved. Proposal: stage this as a sequence of small PRsGiven @tballison's core objection was scale/maintenance risk of a big bang change, I think this whole effort would merge faster broken into independently reviewable, independently testable PRs — mostly a split of what already exists here, not a rewrite:
Would drop or defer indefinitely:
Each stage above is independently testable (unit + e2e) and independently mergeable, which should make review a lot less daunting than reviewing ~3.9k lines at once. |
Sorry, something went wrong.
|
This sounds great and goes exactly in the direction I'm hoping. Multiple tickets = real collaboration and proper pacing I'll close this and post the first suggested change but keep the overall thread alive here unless you can do something in jira after a couple tickets land. I like the feedback's instinct because shaping the API is by far the most important part. Honestly I understand this is a big feature and I appreciate the time you're taking to look into it. seriously. |
Sorry, something went wrong.
First slice of the typed Document contract, per review on apache#2921: the Document envelope, Dublin Core DocumentMetadata, the lossless tagged metadata tail, and ParseStatus. FetchAndParseReply.document is additive: the legacy fields/status stay untouched, so no client breaks. Tail values mirror Tika's String[]-backed metadata model: every entry is a typed array, tagged by the declared Property element type, so declared integer sequences (pdf:charsPerPage, tiff:BitsPerSample) arrive as int64s per element and dates as Timestamps. Untyped keys stay strings, never guessed; if any element refuses its declared type the whole entry falls back to strings. Deferred to follow-up PRs: per-format transformers, the structured content tree, embedded-document recursion. Dropped per review: FormatCategory, the ParseBytes RPC.
| Back | FazBrowse Home | New Git URL |
Summary
Follow-up to #2916, reshaped per the review there. Instead of mirroring Tika's open metadata taxonomy in protobuf (~5k lines of proto, per-format messages), this PR types the thing that is actually stable: the parsed document. One small contract — document.proto is 208 lines — and format specifics live in per-parser mapping code, never in the wire.
FetchAndParseReply.fields (map<string,string>, field 2, now reserved) is replaced by FetchAndParseReply.document.
How this answers the #2916 review
The shape
Deliberately not in this PR (follow-ups, each its own PR)
Open decisions where reviewer preference wins
Client migration
Test plan
Downstream context: this contract is what the OpenNLP gRPC work (OPENNLP-1833) will consume as input — Tika parse → typed document → NLP/embeddings without re-parsing strings.