adityamparikh opened a new pull request, #231:
URL: https://github.com/apache/solr-mcp/pull/231
## What
`get-collection-stats` made six Solr requests per call. It now makes three.
| Request | Before | After |
|---|---|---|
| Collections API `LIST` pre-flight | 1 | 0 |
| `/admin/luke` | 1 (all fields walked, with per-field flags) | 1
(`show=index`, `numTerms=0`) |
| `*:*` `rows=0` query | 1 | 1 |
| `/admin/metrics` (node-wide) | 3 (cache, `/select`, `/update`) | 1
(comma-separated `prefix`) |
| **Total** | **6** | **3** |
## Why
- **The pre-flight was redundant.** The Luke request that follows it already
404s on an unknown collection. That 404 (`ErrorCode.NOT_FOUND.code`) is now
turned into the same `Collection not found: … Hint: call list-collections`
error.
- The pre-flight also made the tool fail on standalone Solr, where `LIST`
is not available.
- A blank or null name is rejected up front, because `""` reaches Solr as
a Jetty 400, not a 404.
- `validateCollectionExists` is deleted. Its shard-prefix branch could
never match, because `LIST` returns collection names only.
- **Three metrics requests became one.** Each metrics request returned every
core on the node and was parsed in full. The Metrics API accepts a
comma-separated `prefix`, so one request now feeds both the cache and handler
extractors. If metrics are unavailable, both fields are still null, as before.
- **Luke did work nobody used.** `includeIndexFieldFlags=true` made Solr
walk every field to build flags that `buildIndexStats` never reads. Only
`numDocs` and `segmentCount` are used, and both come from the `index` section.
- **The tool description was wrong.** It said `cacheStats`/`handlerStats`
are always null on Solr 10 because `/admin/mbeans` was removed. The code reads
`/admin/metrics`, so the description now says they *may* be null.
`getCacheMetrics`/`getHandlerMetrics` no longer make their own `LIST` call
either. For an unknown collection they return null, because its core is absent
from the metrics response.
## Tests
- `CollectionServiceTest`:
- Not-found now stubs a Luke 404.
- New tests cover a blank name and a non-404 Solr error, which propagates.
- A new test asserts that stats makes one metrics request and no `LIST`.
- The reflection tests of the deleted method are removed.
- `CollectionServiceIntegrationTest`: new real-Solr case for an unknown
collection. The existing test that asserts populated cache and handler stats
passes with the combined prefix.
- `./gradlew build`: 423 tests, 0 failures, 0 skipped.
`check-health` still makes two requests (ping + query). It is unchanged on
purpose: the ping honours the healthcheck file.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]