Repository navigation
feat(schema): return list-fields as FieldListing records with FieldFlag flags - #293
Closed
adityamparikh wants to merge 6 commits into
Closed
adityamparikh wants to merge 6 commits into
adityamparikh wants to merge 6 commits into
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>
|
Contributor
Author
|
Folded into #288, whose branch now includes this commit, so |
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 #288 (
list-fields) and #292 (FieldFlags): review the last commit only. Rebased once both merge.Summary
list-fieldsandsolr://{collection}/fieldsnow return aFieldListingrecord instead of Luke'sfieldsandinfosections as maps. Each field's flag letters are decoded into SolrJ'sFieldFlag, the enumget-schemauses since #292, so Luke'sinfo.keylegend is no longer needed."platform": { "type": "string", - "schema": "I-SD------OF-----l", + "flags": ["INDEXED", "STORED", "DOC_VALUES", "OMIT_NORMS", "OMIT_TF", "SORT_MISSING_LAST"], "docs": 61 } -"info": {"key": {"I": "Indexed", "T": "Tokenized", ...}, "NOTE": "..."}docsis aLong, so a distributed sum past 2^31 does not depend on how it was parsed (SolrJ'sLukeResponse.FieldInfocasts it toInteger).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.@JsonAnySetter @JsonAnyGettercatch-all and written back at the same level.DOC_VALUESfields and sort only on ones withoutMULTI_VALUED.Evidence
"schema": "I-SD------OF-----l"againstinfo.keyto learn thatplatformhas docValues; faceting on the schemalesstext_generalplatformreturned an empty facet because the missingDwent unnoticed.After:
"flags": ["INDEXED", "STORED", "DOC_VALUES", ...].SchemaServiceTest:listFields_decodesFlagsAndLeavesOutTheInfoAndIndexSectionspins the exact JSON;listFields_keepsADistributedDocCountPastIntegerMax(3,000,000,000);listFields_keepsTheLettersWhenOneIsNotAKnownFlag("I-S-----------Z"gives no flags and keeps the letters).ListFieldsIntegrationTest.decodesLukeFlagLettersIntoFieldFlagson real Solr:genre_s(*_s, string) hasINDEXED,STORED,DOC_VALUES;year_i(pint) hasDOC_VALUESand notMULTI_VALUED. The existing dynamicBase, point-field and two-shard tests pass on the record.McpClientIntegrationTestBase.listShowsFieldsReturnsIndexedFields, through Spring AI's serialization: noinfo,idhasflagswithINDEXEDandSTORED, noschemaletters../gradlew build: 478 tests, 0 failures, 0 skipped../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.Merge Danger
Door: two-way
Blast Radius: list-fields-consumers
list-fieldsis new in #288, so no released client reads its shape. Against #288 the JSON changes:schemaletters becomeflags,infois gone.🤖 Generated with Claude Code