feat(collection): add create-collection tool and dedicated collection package#57
Merged
epugh merged 7 commits intoapache:mainfrom Mar 9, 2026
Merged
Conversation
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>
4ed3df8 to
859118b
Compare
Add ConferenceEndToEndIntegrationTest using the DevNexus 2026 sample data in a 'conferences' collection. Tests the full workflow: create collection → index 116 JSON documents → search, filter, facet, and paginate results → verify collection stats. Signed-off-by: Aditya Parikh <adityamparikh@gmail.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
- S1118: Add private constructor to CollectionUtils utility class - S1488: Inline shardMatch variable that was immediately returned - S7467: Replace unused caught exceptions with _ (Java 25) 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>
epugh
reviewed
Mar 9, 2026
Contributor
There was a problem hiding this comment.
can we move this to src/test/resources?
| } | ||
|
|
||
| /** | ||
| * Creates a new Solr collection (SolrCloud) or core (standalone Solr). |
Contributor
There was a problem hiding this comment.
Let's remove standalone, it's our past, not our future, and we don't do much aroudn testing of it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CollectionService,CollectionUtils, andDtosfrom themetadatapackage into a new dedicatedcollectionpackage, separating collection management from schema introspection (SchemaServicestays inmetadata)create-collectionMCP tool toCollectionServicethat creates Solr collections/cores with sensible defaultsCollectionCreationResultDTO returned by the new toolNew tool:
create-collection{ "name": "my_collection", "configSet": "_default", "numShards": 1, "replicationFactor": 1 }All fields except
nameare optional and default to_default,1, and1respectively. Works with both SolrCloud and standalone Solr viaHttp2SolrClient.Test plan
./gradlew build)createCollection_createsAndListable) creates a collection against a live Testcontainers Solr instance and verifies it appears inlistCollections()metadataimports replaced withcollectioninMain,MainTest,McpToolRegistrationTestNotes
SchemaServiceis intentionally left inmetadata— a follow-up PR will rename that package toschemasb4branch (Spring Boot 4 / Spring AI 2.0)🤖 Generated with Claude Code