Skip to content

fix(indexing): XML record elements are wrappers, not field prefixes - #204

Closed
adityamparikh wants to merge 5 commits into
apache:mainfrom
adityamparikh:fix/xml-record-fields
Closed

adityamparikh wants to merge 5 commits into
apache:mainfrom
adityamparikh:fix/xml-record-fields

Conversation

@adityamparikh

Copy link
Copy Markdown
Contributor

Stacked on #201 (the CSV/XML/Markdown sample data); the first three commits here are that PR's. Merge #201 first and this diff shrinks to the XML fix.

Summary

The XML creator flattened every element by its full path from the record element, so

<shows><show><id>x</id><title>T</title><genres>a</genres><genres>b</genres></show></shows>

produced show_id, show_title, show_genres and no id at all. Solr minted a UUID per document, re-indexing duplicated instead of replaced, and XML was the one format whose documents did not match the same data in JSON, CSV or Markdown. Anyone following the tutorial with XML had to learn a second set of field names.

The record element (the root for a single document, each repeated child for many) is now a wrapper: its child elements are the fields, named after themselves, nested elements still flatten below that with underscores (author_name), and attributes keep the _attr suffix: unqualified on the record (id_attr), qualified by the element on a child (name_lang_attr).

What changed

  • XmlDocumentCreator.addRecordFields replaces the prefixed walk for both the single- and multi-document strategies.
  • XmlIndexingTest expectations drop the record prefix (52 assertions); ShowsSampleDataTest now asserts XML equals JSON field for field, the same check CSV and Markdown already passed.
  • Tool description and javadoc describe the mapping.

Compatibility

Field names change for anyone indexing XML today (book_title becomes title). No test or doc on main relied on the old names beyond XmlIndexingTest itself, and at 0.0.2-SNAPSHOT the old mapping was a defect rather than a contract.

Part of a set with #202 and #203; independent, any merge order.

Verification

  • ./gradlew build on Java 25: green.
  • ./gradlew nativeTest -Pnative on GraalVM CE 25.0.2: green.
  • Measured against a running server: shows.xml indexes 61 documents in one call with id, title, platform and multi-valued genres, the same names the JSON path produces.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CiUHyyXLTo9ATdgg8eRFZJ

adityamparikh and others added 5 commits September 13, 2026 16:23
shows.json is the dataset the tutorial and the hackathon card index. The
same 61 shows now exist as shows.csv, shows.xml and one Markdown file per
show under shows-markdown/, so the indexing walkthrough can be followed in
whichever format a reader has.

CSV carries multi-valued fields as repeated column headers, which the CSV
creator turns into one value per non-empty cell under the same field name.
Markdown puts every field in YAML front matter and the description in the
body. XML uses one <show> element per record with repeated children for
lists; the XML creator prefixes those fields with the record name
(show_title) and carries no plain id, which ShowsSampleDataTest pins along
with the field-for-field equality of the other three formats.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CiUHyyXLTo9ATdgg8eRFZJ
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
RAT audits XML; CSV, JSON and Markdown data files are exempt.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CiUHyyXLTo9ATdgg8eRFZJ
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
…est binary

Spring AOT's resource hints cover every *.json file, which is why shows.json
was already available to native tests; the new flavours were not, and
ShowsSampleDataTest failed natively with missing-resource NPEs.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CiUHyyXLTo9ATdgg8eRFZJ
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
The XML creator flattened every element by path from the record element, so
<show><id>x</id><title>T</title></show> produced show_id and show_title and
no id at all; Solr then minted a UUID per document and re-indexing duplicated
rather than replaced. XML was the one format whose documents did not match
the same data in JSON, CSV or Markdown, and the only one where a reader had
to learn different field names for the tutorial's later prompts.

The record element (the root for a single document, each repeated child for
many) is now a wrapper: its child elements are the fields, named after
themselves, nested elements still flatten below that with underscores, and
the record's own attributes keep the _attr suffix. ShowsSampleDataTest now
asserts XML equals JSON field for field, and XmlIndexingTest's expectations
drop the record prefix.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CiUHyyXLTo9ATdgg8eRFZJ
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
Only the record element's own attributes are unqualified (id_attr); an
attribute on a child keeps the element name (name_lang_attr), as before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CiUHyyXLTo9ATdgg8eRFZJ
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
@adityamparikh

Copy link
Copy Markdown
Contributor Author

Closing: this was stacked on #201 and so carried the CSV, XML and Markdown sample files, which are unrelated to the XML fix. The same change, rebased onto main as a single commit with only XmlDocumentCreator, XmlIndexingTest and the tool docs, is the replacement PR linked below. #201's ShowsSampleDataTest now expects the fixed mapping and should merge after it.

Replacement: #205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant