sigram opened a new pull request, #5403: URL: https://github.com/apache/solr/pull/5403
https://issues.apache.org/jira/browse/SOLR-18678 Part 1 of [SOLR-18674](https://issues.apache.org/jira/browse/SOLR-18674): field-level schema metadata. # Description Schemas can now carry purely descriptive metadata (a description, an owner, a unit, ...) on the schema itself, on field types, fields and dynamic fields. It is stored in a `<meta>` child element with typed entries: ```xml <field name="id" type="string" indexed="true" stored="true"> <meta> <str name="dc:description">unique document identifier</str> <int name="ext:max_length">32</int> <bool name="ext:internal">false</bool> <arr name="dc:subject"><str>catalog</str><str>pk</str></arr> <lst name="ext:owner"><str name="team">catalog</str></lst> </meta> </field> ``` Metadata is returned as a `meta` property (a JSON object) and is persisted in the managed schema. It never affects indexing, querying or schema compatibility. Older Solr versions ignore unknown child elements, so the format is safe during a rolling upgrade; a node running an older version that rewrites the managed schema drops the metadata, which the ref guide notes. The vocabulary and configurable limits are left to SOLR-18679, and Schema API extensions (`withMeta`, schema-level writes) to SOLR-18680. # Implementation - `SchemaMetadata` is an immutable value holding a unique-key map. Its XML parser is strict: an unknown tag, a missing or duplicate name, more than one `<meta>` element, a malformed typed value, or nesting deeper than 10 levels fails the load with a 400 that names the element and key. - `SchemaMetadataValidator` is the single validation entry point, with minimal rules marked `TODO SOLR-18679`: key syntax, value types, key length 64, string length 256, 64 entries, nesting depth 3, and characters that XML can store unchanged. - `SchemaField` and `FieldType` keep metadata out of their args and expose `getMetadata()`. A `meta` object in Schema API JSON is accepted for fields, dynamic fields and field types. Metadata survives `replaceFieldType` and the Schema Designer's language restore and field updates. - `SchemaXmlWriter` writes metadata as `<meta>` children. Its `writeNamedList` now writes a normal `<lst>`; the similarity-specific handling moved into `writeSimilarity`. `$` in metadata strings is written as `$$`, so values survive the `${...}` property substitution applied when the schema is loaded. - `description`, `meta` and `metadata` used as attributes get a hint pointing to `<meta>` in the existing "invalid property" errors. Two related fixes: - A field-level `postingsFormat` or `docValuesFormat` was persisted to the managed schema as `false`; it now keeps its value. - `DataConfigNode` iterated children grouped by tag in random order; it now uses document order, as `DOMConfigNode` already does. I used Claude Code (Opus 5.5) to help write the code, tests and docs, and reviewed / modified as necessary. # Tests - New `TestSchemaMetadata`: loading on all four levels, persist and reload round trip (every type, nested values, document order, `$` and `${...}`), managed-schema changes keeping metadata, rejected input (unknown tags, duplicate names and elements, malformed values, limits, unsupported characters, misspelled field type metadata, reserved attributes), and that persisted `<field>` elements carry only attributes older nodes accept. - New `TestDataConfigNode`, and additions to `TestSchemaDesigner` and `TestSchemaDesignerConfigSetHelper`. - Existing schema, Schema REST API, Schema Designer, core config and similarity suites pass, as does `./gradlew check -x test`. Not covered yet: a backcompat test that starts the previous release on a schema written by this code. # Checklist - [x] I have reviewed the guidelines for [How to Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my code conforms to the standards described there to the best of my ability. 🤖 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]
