Skip to content

feat(compat): add Solr 10 support with /admin/metrics migration#59

Open
adityamparikh wants to merge 12 commits intoapache:mainfrom
adityamparikh:solr-10
Open

feat(compat): add Solr 10 support with /admin/metrics migration#59
adityamparikh wants to merge 12 commits intoapache:mainfrom
adityamparikh:solr-10

Conversation

@adityamparikh
Copy link
Contributor

@adityamparikh adityamparikh commented Mar 6, 2026

Depends on: #55 (JSON wire format)
Followed by: #58 (SolrJ 10 upgrade)

Summary

Verifies that the JSON wire format (introduced in #55) works correctly with Solr 10, migrates metrics collection from the deprecated /admin/mbeans endpoint to the /admin/metrics API, and extends the CI matrix to cover all supported versions.

  • Solr 10 compatibility verified: all integration tests pass with solr:10-slim using the JSON wire format (no JavaBin)
  • Metrics API migration: getCacheMetrics() and getHandlerMetrics() in CollectionService now use /admin/metrics (available since Solr 7.1+) instead of /admin/mbeans (removed in Solr 10). All MBeans code has been removed.
  • Logging added: SLF4J logging added to all silent catch blocks across CollectionService, IndexingService, SchemaService, and JsonUtils. Logging is visible only in HTTP profile (STDIO remains silent for MCP protocol).
  • CI matrix extended: build-and-publish.yml now tests against Solr 8.11, 9.4, 9.9, 9.10, and 10 on every PR and push to main
  • Integration tests strengthened: cache and handler metrics are validated with strong assertions against real Solr via Testcontainers (no more conditional/soft assertions)
  • Docs updated: AGENTS.md updated to reflect Solr 10 as a tested, supported version

PR chain

  1. feat(config): switch Solr wire format from JavaBin to JSON #55feat/json-wire-formatmain (JSON wire format)
  2. feat(compat): add Solr 10 support with /admin/metrics migration #59solr-10main (this PR: Solr 10 compat, built on feat(config): switch Solr wire format from JavaBin to JSON #55)
  3. feat(deps): upgrade solr-solrj from 9.9.0 to 10.0.0 #58solrj-10main (SolrJ 10 upgrade, built on feat(compat): add Solr 10 support with /admin/metrics migration #59)

Merge in order. After #55 merges, this PR will show only the Solr 10-specific commits.

Changes

CollectionService.java

  • Removed all /admin/mbeans code (constants, request building, response parsing)
  • Added /admin/metrics API integration with GenericSolrRequest for cache and handler metrics
  • Handles both NamedList and LinkedHashMap response types from SolrJ deserialization
  • Added SLF4J logging to all catch blocks

CollectionServiceIntegrationTest.java

  • Strong assertNotNull assertions for cache stats (queryResultCache, documentCache, filterCache) and handler stats (selectHandler, updateHandler)

CollectionServiceTest.java

  • Rewritten mock data helpers to use Metrics API response format

IndexingService.java, SchemaService.java, JsonUtils.java

  • Added SLF4J logging to previously silent catch blocks

.github/workflows/build-and-publish.yml

New solr-compatibility job with matrix strategy testing Solr 8.11, 9.4, 9.9, 9.10, and 10.

AGENTS.md

Updated Solr 10 section: /admin/mbeans no longer used, /admin/metrics works on Solr 9 and 10.

Test plan

  • ./gradlew build passes (default Solr 9.9)
  • ./gradlew test -Dsolr.test.image=solr:10-slim passes
  • ./gradlew test -Dsolr.test.image=solr:9.10-slim passes
  • All existing Solr 8.11, 9.4, 9.9 tests continue to pass
  • Cache and handler metrics validated against real Solr via Testcontainers

🤖 Generated with Claude Code

adityamparikh and others added 2 commits February 28, 2026 23:38
Replace the default BinaryResponseParser (wt=javabin) with a custom
JsonResponseParser (wt=json) for future-proofing and improved
debuggability.

The JsonResponseParser converts Solr's JSON response envelope into the
NamedList<Object> tree that SolrJ typed response classes expect:
- JSON objects → SimpleOrderedMap (extends NamedList, implements Map,
  satisfying both QueryResponse's NamedList casts and SchemaResponse's
  Map cast)
- JSON objects with numFound+docs → SolrDocumentList
- Flat alternating arrays [String, non-String, ...] → SimpleOrderedMap
  (Solr's json.nl=flat encoding for facet counts)
- All other arrays → List
- Decimal numbers → Float (matching JavaBin's float type, required by
  SchemaResponse's (Float) version cast)
- Small integers → Integer, large integers → Long

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
Extract JsonResponseParser instantiation into a dedicated @bean method
so it can be injected as a dependency into solrClient(), making the
wiring explicit and enabling overriding in tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
@adityamparikh adityamparikh marked this pull request as draft March 6, 2026 17:09
adityamparikh and others added 4 commits March 6, 2026 19:27
Replace the static new ObjectMapper() with Spring's auto-configured
ObjectMapper bean injected via constructor. Use MediaType.APPLICATION_JSON_VALUE
for the content type constant instead of a raw string literal.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
…'s ObjectMapper

Extract URL normalization tests from SolrConfigTest into a dedicated
SolrConfigUrlNormalizationTest annotated with @jsontest, so Spring's
auto-configured ObjectMapper is injected rather than using new ObjectMapper().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
… Solr 10

SolrInfoMBeanHandler (and thus the /admin/mbeans endpoint) was removed in
Solr 10. When getCacheMetrics() or getHandlerMetrics() call this endpoint on
a Solr 10 server, SolrJ throws RemoteSolrException (a RuntimeException) because
the server returns an HTML 404 page instead of JSON.

Widen the catch in both methods to include RuntimeException so the server
degrades gracefully (returning null for cache/handler stats) rather than
propagating the exception. The integration tests already handle null stats,
so all tests now pass with solr:10-slim.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
Add Solr 9.10 and 10 to the CI compatibility matrix, running integration
tests against all supported versions (8.11, 9.4, 9.9, 9.10, 10) on every
PR and push to main.

Also update AGENTS.md to document Solr 10 compatibility status: the
/admin/mbeans endpoint removal is handled gracefully, and all other
functionality is verified working with solr:10-slim.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
adityamparikh added a commit to adityamparikh/solr-mcp that referenced this pull request Mar 8, 2026
…o sb4

Incorporates:
- feat(config): switch Solr wire format from JavaBin to JSON (apache#55)
- fix(collection): catch RuntimeException from removed /admin/mbeans in Solr 10 (apache#59)
- feat(ci): add Solr 9.10 and 10 compatibility testing (apache#59)
- feat(deps): upgrade solr-solrj from 9.9.0 to 10.0.0 (apache#58)

Adapted JsonResponseParser for Jackson 3 (tools.jackson.databind).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
@adityamparikh adityamparikh marked this pull request as ready for review March 8, 2026 21:27
@adityamparikh adityamparikh changed the title feat(compat): add Solr 10 support with graceful mbeans degradation feat(compat): add Solr 10 support with /admin/metrics migration Mar 8, 2026
adityamparikh and others added 6 commits March 8, 2026 19:57
Move CollectionService, CollectionUtils, and Dtos from the metadata
package into a new dedicated collection package. This separates
collection management from schema introspection (SchemaService stays
in metadata).

Add create-collection MCP tool to CollectionService:
- Accepts name (required), configSet, numShards, replicationFactor
- Defaults: configSet=_default, numShards=1, replicationFactor=1
- Uses CollectionAdminRequest.createCollection() for both SolrCloud
  and standalone Solr via Http2SolrClient
- Returns CollectionCreationResult DTO with name, success, message,
  and createdAt timestamp

Add CollectionCreationResult record to Dtos.java.

Update unit tests with correct 2-arg Mockito stubs to match
CollectionAdminRequest.process() call signature.
Add integration test asserting the new collection appears in
listCollections() after creation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
116 session documents covering all tracks and days (March 4-6 2026)
for use with the create-collection and index-documents MCP tools.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
- Add isBlank() guard in createCollection() to throw
  IllegalArgumentException before calling SolrJ, ensuring consistent
  behavior regardless of SolrJ version
- Update README: add create-collection to feature list, fix all tool
  names to kebab-case, split into Search/Indexing/Collections/Schema
  sections, list all three indexing tools separately

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
Add @PreAuthorize("isAuthenticated()") to the createCollection method
to prevent unauthorized collection creation via the MCP tool, consistent
with the pattern used in SearchService and IndexingService.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
- Remove unnecessary local variable in validateCollectionExists (S1488)
- Add private constructor to CollectionUtils utility class (S1118)

Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Aditya Parikh <adityamparikh@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant