Repository navigation
feat(schema): add list-fields, Solr's Luke field listing as FieldFlag records - #288
Merged
Merged
Conversation
…gh (apache#241) get-schema returns the full schema definition (about 35 KB on _default) and cannot say which dynamic fields hold data. list-fields sends one collection-level Luke request (numTerms=0, includeIndexFieldFlags=false) and returns Luke's fields and info sections as Solr sends them; info.key decodes the schema flag letters. The index section is left out: get-collection-stats covers it, and its directory entry names a path on the Solr host. The same JSON is served as the solr://{collection}/fields resource, with collection-name completion. The server adds no logic of its own. The tool description says how to read Solr's answer: point and docValues-only fields have no docs count (missing, or 0 on 9.11+/10.1+), and before Solr 9.11/10.1 Luke reads one shard of a multi-shard collection (SOLR-8127). The field tools now name each other so a model can tell them apart: get-schema is definitions and patterns, get-collection-stats is index size and performance, and search drops its suffix guide in favour of calling list-fields first. Its undefined-field and facet error hints point to list-fields. A registration test pins the cross-references. Closes apache#241 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
- Read Luke's raw NamedList with solrClient.request() instead of process(), which also builds SolrJ's typed LukeResponse: that parse casts each docs count to Integer and fails on a distributed sum past 2^31. - Move the docValues advice to the error path it applies to. Solr rejects a facet or sort on an unsuitable field with a 400, which gets the generic hint; RESPONSE_ERROR is a client-side parse failure. The search description and search-collection prompt also say sorting needs a single-valued field. - ListFieldsIntegrationTest: an unknown collection is a SolrException 404, and the comment on point-field docs names the right Solr code path. - Test against Solr 9.11, the first release with distributed Luke: added to both compatibility matrices and the tested-version lists. The full suite passes on solr:9.11-slim, which runs the two-shard test's distributed branch. - Update the tool and resource counts and lists in THREAT_MODEL.md, CHANGELOG.md and the client docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
- java:S1192: the Luke key constant LUKE_FIELDS_KEY ("fields") made Sonar
ask the add-fields parameter check to reuse it, though that "fields" is
an error-message name, not a Luke key. One list of the Luke sections to
pass through replaces the two key constants.
- java:S5785: assertNotEquals instead of assertTrue(a != b).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
get-schema returned SolrJ's SchemaRepresentation, whose FieldTypeDefinition nests each type's properties under "attributes" and serializes every unset analyzer slot as null: 32 KB on _default against the Schema API's own 23 KB. It now returns a CollectionSchema record with typed components for the properties clients read (fields, field types, analyzers, copy fields). Every other property Solr sends is kept in a catch-all map, collected by @JsonAnySetter when the response is converted and written back at the same level by @JsonAnyGetter, so the JSON a client receives is the Schema API's, key for key, and a property a later Solr version adds is passed on rather than dropped. The response is read with solrClient.request() and converted by Jackson: the Schema API's JSON objects arrive as SimpleOrderedMap, a java.util.Map, so no mapping code is needed. Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
The Schema API's boolean properties (indexed, stored, docValues,
multiValued, omitNorms, sortMissingLast, ...) are now reported on every
field, dynamic field and field type as "flags", a set of SolrJ's
FieldFlag, the enum Luke's flag letters decode to. list-fields uses the
same enum, so both tools describe a field's flags the same way.
Only properties set to true appear: a flag property set to false, or
inherited from the field type, is not reported. required, which
FieldFlag has no counterpart for, stays a typed property; other
properties without one (useDocValuesAsStored, large, default) stay in
the catch-all unchanged.
Flags are written as their constant names (DOC_VALUES). Jackson 3 writes
enums with toString() by default, which for FieldFlag is Luke's legend
text ("D - DocValues").
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
…ag flags
list-fields passed Luke's fields and info sections through as maps. An
agent had to decode each field's schema letters ("I-SD------OF-----l")
with the info.key legend to learn, for example, whether it can facet on
the field.
It now returns a FieldListing record. Each field's letters are decoded
into SolrJ's FieldFlag, the enum get-schema uses, so the info legend is
no longer needed and is left out. docs is a Long, so a distributed sum
past 2^31 no longer depends on how the value was parsed. Every other
property Luke sends is kept in a catch-all and written back at the same
level.
The letters are decoded with FieldFlag.getFlag rather than
LukeResponse.FieldInfo.parseFlags, which adds getFlag's result without a
null check and so would throw on a letter a later Solr version adds. On
an unknown letter the letters are kept as they are.
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
adityamparikh
force-pushed
the
feat/list-fields-241
branch
from
November 24, 2026 19:04
4a3c713 to
8b5692c
Compare
|
This was referenced Nov 24, 2026
adityamparikh
added a commit
to adityamparikh/solr-mcp
that referenced
this pull request
Nov 24, 2026
…ctionSchema get-schema returns the CollectionSchema record since apache#288, so the test reads field names with fields() and name() instead of SchemaRepresentation's getFields() map. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
adityamparikh
added a commit
to adityamparikh/solr-mcp
that referenced
this pull request
Nov 24, 2026
…ration test apache#288 renamed GET_SCHEMA_HINT_FORMAT to LIST_FIELDS_HINT_FORMAT when the undefined-field hint started pointing at list-fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
adityamparikh
added a commit
to adityamparikh/solr-mcp
that referenced
this pull request
Nov 24, 2026
…r:read (#66) list-fields, solr://{collection}/fields and the fields resource's collection completion arrived with apache#288 on isAuthenticated(). They are read-only, so they take McpAuthorities.READ and join the expected scope map and the http.md scope table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
This was referenced Nov 24, 2026
adityamparikh
added a commit
to adityamparikh/solr-mcp
that referenced
this pull request
Nov 24, 2026
…ueryFields apache#271 gives a collection created without a configSet its own copy of _default, so rule 1 no longer says collections share a schema by default: only a named configSet is shared. indexing.md and troubleshooting.md say the same about guessed fields and add-fields "already exists". apache#288 added list-fields and solr://{collection}/fields. The tool table lists it next to get-schema, the description names it, and the search error rows point to it, as the server's own hints now do. solr-versions.md states list-fields' version-dependent counts. apache#291's queryFields local-params error gets a troubleshooting row, and the Markdown empty-input message is the one the server now returns. SolrSkillFormatTest is reformatted to google-java-format (apache#266). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
adityamparikh
added a commit
to adityamparikh/solr-mcp
that referenced
this pull request
Nov 24, 2026
…r:read (#66) list-fields, solr://{collection}/fields and the fields resource's collection completion arrived with apache#288 on isAuthenticated(). They are read-only, so they take McpAuthorities.READ and join the expected scope map and the http.md scope table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
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.



Stacked on #292 (
get-schemarecords,FieldFlags): its two commits are included here because the field flags reuse itsFieldFlags. Review the other four; once #292 merges this is rebased and they are all that remain.Summary
Adds
list-fields: the fields that hold data in a collection, as Solr's Luke handler reports them, returned as aFieldListingrecord with each field's flags decoded into SolrJ'sFieldFlag. One collection-level Luke request.FieldFlagnames, the enumget-schemauses since feat(schema): return get-schema as CollectionSchema records with FieldFlag flags #292, so Luke'sschemaletters ("I-SD------OF-----l") and itsinfo.keylegend are not needed and are left out.FieldFlag.getFlag, notLukeResponse.FieldInfo.parseFlags, which addsgetFlag's result without a null check and would throw on a letter a later Solr version adds. On an unknown letter the letters are kept asschemain the catch-all.docsis aLong, so a distributed sum past 2^31 does not depend on how it was parsed (SolrJ'sLukeResponse.FieldInfocasts it toInteger).@JsonAnySetter @JsonAnyGettercatch-all and written back at the same level.The same JSON is served as
solr://{collection}/fields, with collection-name completion. Where Solr's answer needs reading with care, the tool description says so rather than the server changing it:docscount (missing, or 0 on 9.11+/10.1+), which means "not counted"DOC_VALUESfields, and sort only on ones withoutMULTI_VALUEDSeveral tools talk about fields, so each description now names the tool for the job it doesn't do:
The server instructions and step 1 of
search-collectionfollow the same split, andview-schemapoints atlist-fieldsfor which dynamic fields are in use.McpToolRegistrationTest.fieldToolDescriptionsRouteToEachOtherpins the cross-references.Closes #241. It answers the first two questions of the dev@ Discovery Handler proposal (which fields exist, which are populated) with what Solr has today.
Evidence
get-schemaon_defaultreturns about 35 KB, and a collection holdinggenre_sshows only the pattern*_s. Faceting on the schemalesstext_generalplatformreturned an empty facet, because nothing said it lacks docValues.After:
list-fieldsreturnsgenre_swith"dynamicBase": "*_s", its type,flagsanddocs, andplatform's flags show whetherDOC_VALUESis there.ListFieldsIntegrationTest(Testcontainers):genre_s→dynamicBase*_s,docs2, flagsINDEXED,STORED,DOC_VALUES;idhas nodynamicBase;year_i(pint) has nodocs, hasDOC_VALUESand notMULTI_VALUED; noinfoorindexsectiondocs1, on older Solr exactly one is, with the expectation taken from the Solr versionSchemaServiceTest:listFields_decodesFlagsAndLeavesOutTheInfoAndIndexSectionspins the exact JSON;listFields_keepsADistributedDocCountPastIntegerMax(3,000,000,000);listFields_keepsTheLettersWhenOneIsNotAKnownFlag("I-S-----------Z"gives no flags and keeps the letters).McpClientIntegrationTestBase.listShowsFieldsReturnsIndexedFields, through Spring AI's serialization: noinfo,idhasflagswithINDEXEDandSTORED, noschemaletters../gradlew build(defaultsolr:9.9.0-slim): 478 tests, 0 failures, 0 skipped. This covers the single-core path../gradlew nativeTest -Pnative: 316 successful, 0 failed;ListFieldsIntegrationTestand the MCPlist-fieldstests (HTTP and STDIO) pass in the native image. The skipped tests are the@DisabledInNativeImageMockito tests.10-slim(10.1) joins once test: start embedded ZooKeeper with -DzkRun=true so Solr 10.1 boots #285 lets it boot.Merge Danger
Door: two-way
One new read-only tool and resource; reverting removes them.
Blast Radius: descriptions
The
searchdescription no longer carries the dynamic-suffix guide, and its error hints namelist-fieldsinstead ofget-schema. A client that relied on that text to guess field names now has to calllist-fields, which is the point, but it changes how existing clients are steered. The compatibility matrices gain a9.11-slimjob.🤖 Generated with Claude Code