fix(biochem): support Solr 9 nested stoichiometry children - #233
Merged
samseaver merged 2 commits intoAug 28, 2026
Merged
Conversation
…rying the removed parent field Use the child transformer to retrieve stoichiometry alongside thermodynamics and normalize participants at the API boundary. Restrict nested batch and reverse lookups to parent documents, and omit the nested child path from reaction quick-search fields.
VibhavSetlur
added a commit
to VibhavSetlur/ModelSEED-UI
that referenced
this pull request
Aug 28, 2026
…ging base Fix a pre-existing semantic conflict where PR ModelSEED#233 merged after PR ModelSEED#235 (e788d98) without it, leaving expectations naming staging.modelseed.org/solr. The reactions_staging collection name is unchanged because the shared instance serves both core sets.
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.
Summary
Solr 9 moved reaction stoichiometry from a single string field on the parent document to one nested child document per participant (
doc_type:stoichiometry). This broke the UI in two ways, both fixed here:RXN_SEARCH_FIELDSstill containedstoichiometry, which no longer exists as a queryable parent field →undefined field stoichiometry.[child]transformer was scoped todoc_type:thermodynamicsonly, so the nested stoichiometry children were silently dropped.Two query paths also lacked a parent-document filter, so child documents could leak into results on the nested index.
Changes (
lib/api/biochem.ts)StoichiometryParticipantinterface and a purenormalizeStoichiometry()that handles both schemas: nested children (ordered by_nest_path_, withparticipant_charge/participant_formulacarried through) and the legacycoefficient:compound:compartment:0:"name"parent string. It never throws — malformed or missing input yields[].serializeStoichiometry()re-emits the legacy string format, soReaction.stoichiometrykeeps its existing shape and every current consumer is unaffected.participants?: StoichiometryParticipant[]is added alongside it.getReactionById()widens the nested child transformer to[child childFilter="doc_type:thermodynamics OR doc_type:stoichiometry" limit=200]. Thermodynamics children and atom-mapping fields are unchanged.RXN_SEARCH_FIELDS_NESTEDdropsstoichiometryon the nested schema only. A caller-suppliedsearchFieldsstill wins.getCompoundsByIdsWithFields()addsfq=doc_type:compound;findReactionsForCompound()addsfq=doc_type:reactionand, on the nested schema, uses a block join{!parent which="doc_type:reaction"}doc_type:stoichiometry AND compound:<id>(guarded by an id regex, falling back to the legacyequation:*<id>*wildcard otherwise).Schema selection reuses the existing
hasNestedSchema()probe. On the legacy index every emitted URL is byte-identical to before — asserted directly in the tests.Verification
CI mirror, all exit 0:
npm run lint·npx tsc --noEmit·npm run test:run(354 passed, 4 skipped) ·npm run build·npm audit --omit=dev --audit-level=high(0 vulnerabilities) ·git diff --check.New
tests/unit/api/biochemStoichiometry.test.ts(7 tests) covers nested normalization with scrambled_nest_path_order and mixed value types, legacy parse + round-trip, malformed/garbage input, the nested detailfl/fqand preserved thermo + atom-mapping fields, byte-identical legacy URLs, and the parent filters / block join.Checked live against the new index (
reactions_staging) through the exported functions:getReactionById('rxn00001').participants-1 cpd00001 H2O,-1 cpd00012 PPi,+2 cpd00009 Phosphate,+1 cpd00067 H+)has_atom_mapping: true,atom_mapping_confidence: cleanatpdoc_type:reaction, zero child idsfindReactionsForCompound('cpd00002')Notes