feat(indexing): add markdown document indexing - #144
Conversation
Adds an index-markdown-documents MCP tool that indexes markdown content into Solr, complementing the existing JSON/CSV/XML tools. - New MarkdownDocumentCreator (CommonMark + YAML front matter extension; lightweight, reflection-free, native-image safe): front matter entries become sanitized fields, title resolves from front matter or the first H1, heading texts go into a multi-valued headings field, and the plain-text body into content - Missing ids are derived from a SHA-256 content hash so re-indexing the same markdown stays idempotent (matches the tool hint) - Flow-style YAML lists ([a, b, c]) are expanded to multi-valued fields, matching block-style list behavior - index-data prompt accepts markdown/md formats - Unit tests, MCP integration round-trip test, README/AGENTS docs Refs apache#69
…formats Per maintainer feedback on apache#69, the index-markdown-documents tool description now tells clients not to use it for JSON/CSV/XML input (dedicated tools exist), to convert to markdown only when no dedicated tool covers the source format, and to supply a stable front matter id when indexing converted content.
…#144 conflicts) Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com> Conflicts: README.md: kept main's slimmed flat tools table (PR apache#151) and added the index-markdown-documents row in its concise style src/main/java/org/apache/solr/mcp/server/indexing/documentcreator/IndexingDocumentCreator.java: kept both the markdownDocumentCreator field and main's constructor Javadoc, extended with the markdownDocumentCreator @PARAM
|
Hi @shahzadarain — this PR currently has merge conflicts with I've resolved the conflicts by merging current Of course, feel free to resolve the conflicts your own way instead if you'd prefer different choices — happy to close my PR in that case. |
|
Hi @shahzadarain — friendly follow-up on the merge conflicts here. The resolution PR on your fork, shahzadarain/solr-mcp#1, is still open: merging it into If you would rather resolve the conflicts yourself (e.g. by merging upstream |
Merge upstream main to resolve apache#144 conflicts
Resolves the PR apache#144 conflict against apache/solr-mcp main. Textual conflict (AGENTS.md): the branch added markdown to the IndexingService format list while upstream apache#106 moved CollectionService from metadata/ to collection/ on the adjacent line. Both edits kept. Semantic conflict (IndexingService.java): upstream apache#165 added describeIndexedFields() to the json/csv/xml tool responses so MCP clients learn the sanitized Solr field names. The merge was textually clean but left index-markdown-documents alone, silently inconsistent with the other three. Markdown is the format where this matters most, because its field names come from arbitrary YAML front matter keys, so the markdown tool response now reports them too, with a matching integration test mirroring indexJsonDocuments_reportsSanitizedFieldNames. Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
|
Follow-up: this drifted back into conflict after shahzadarain/solr-mcp#1 was merged on 31 July, because more has landed on I've opened a fresh merge PR — shahzadarain/solr-mcp#3 — against Only one real conflict this time, in Post-merge checks, since a clean auto-merge is what hides this class of breakage:
My approval on the code stands. |
|
Reviewed as part of a sweep over the open PRs. The markdown support is thoughtfully done — the Blocking: the branch is currently Worth a second look: the content-hash id makes edits additive. The tool description does say to supply a stable front-matter Two minor things:
The id semantics are the only thing I'd call out as needing a decision rather than a tweak. |
|
I rebased this onto current git remote add aditya https://github.com/adityamparikh/solr-mcp.git
git fetch aditya
git reset --hard aditya/rebase-offer/pr144-markdown-indexingOnly if you want it — no need to take it, and I haven't touched this PR. 387 tests, 0 failures, Three conflicts, and I made a judgement call on two that you should check:
The id-semantics question from my earlier comment is unaffected by any of this and still worth a |
Summary
Adds an
index-markdown-documentsMCP tool that indexes markdown content into Solr, alongside the existing JSON/CSV/XML tools — extracting searchable structure rather than a flat text blob.Closes #69
Design
A new
MarkdownDocumentCreatorfollows the existing strategy pattern inindexing/documentcreator/, parsing with CommonMark-Java 0.28.0 plus its YAML front matter extension (lightweight, reflection-free, so GraalVM native-image safe — no extra hints needed).Field extraction:
FieldNameSanitizer; block- and flow-style lists become multi-valued fields)ididif present, otherwise SHA-256 of the inputtitletitle, else first level-1 headingheadingscontentThe
index-dataMCP prompt also acceptsmarkdown/mdformats.Maintainer feedback from #69, addressed
Stable id / idempotency: when front matter supplies no
id, the document id is derived deterministically from a SHA-256 hash of the input, so re-indexing identical markdown overwrites the same document — matching the tool'sidempotentHint. Since LLM-driven conversion of other formats to markdown is non-deterministic, the tool description also instructs clients to supply a stable front matteridwhen indexing converted content.Tool steering: the tool description now reads: "Do NOT use for JSON/CSV/XML input; use index-json-documents, index-csv-documents, or index-xml-documents instead. Only convert source content to markdown when there is no dedicated tool for the source format, and supply a stable 'id' in the YAML front matter when doing so."
Testing
MarkdownIndexingTest— 10 unit tests: front matter extraction, title resolution (front matter wins over H1), heading collection, plain-text body with formatting stripped, field name sanitization, flow- and block-style YAML lists, front matter id, content-hash id stability, empty-input rejectionmarkdownandmdformats inIndexingServiceTestMcpClientIntegrationTestBase: index markdown via the tool, then find it by front matter id (runs across all transport × runtime combinations)listToolsReturnsExpectedToolsand behavior hints asserted intoolsExposeBehaviorHints./gradlew spotlessApplyclean; unit tests green locally on JDK 25Docs updated: README tool table, AGENTS.md format/creator lists.