Skip to content

SOLR-18612: solr/core: SimpleOrderedMap for search-side response sections - #5365

Open
isaric wants to merge 4 commits into
apache:mainfrom
isaric:SOLR-18612-core-search
Open

isaric wants to merge 4 commits into
apache:mainfrom
isaric:SOLR-18612-core-search

Conversation

@isaric

@isaric isaric commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/SOLR-18612

Description

SIP-22 step 5, fourth slice (after #5311 SolrJ, #5326 core init args, #5336 admin/backup responses). This one covers the search-side solr/core sites where a NamedList is built with keys that never repeat: 22 sites in 14 Java files, plus the one Admin UI screen that read one of them in the flat form.

Independent of #5336 (no shared files except the upgrade-note page: both add a "Response Format" section with their own bullets, so whichever merges second gets a one-line merge of the bullet lists).

Solution

Response-visible, each keyed by something unique (term, document key, field name, fixed names):

  • LukeRequestHandler: a field's histogram (topTerms stays a NamedList: indexedToReadable() is not injective for legacy Trie precision terms, so readable keys can repeat)
  • MoreLikeThisHandler: interestingTerms with mlt.interestingTerms=details
  • MoreLikeThisComponent: the SolrCloud moreLikeThis section, keyed by document, as single-node already was
  • SearchHandler: the debug/explain section emitted for an empty result
  • IGainTermsQParserPlugin (featuredTerms; docFreq stays a NamedList because the producer adds each featured term a second time with a null value, a pre-existing bug worth its own JIRA), TextLogisticRegressionQParserPlugin (logit)
  • DirectUpdateHandler2.split: the Core Admin SPLIT response (timing, failed)

Internal, never serialized as is: the spellchecker and JSON-facet config conversions (SpellCheckComponent, FacetParser), SignificantTermsQParserPlugin's working maps, the managed-resource initArgs (ManagedResource/RestManager; the response already converts it to a map), and the grouping shard-result serializers (SearchGroupsResultTransformer, TopGroupsResultTransformer), whose output travels between shards as javabin and is read back as a NamedList either way.

Admin UI: the Schema Browser's term-info panel parsed Luke's topTerms and histogram by index as a flat [name, value, ...] array, so it rendered nothing once they became objects (this is what broke the Admin UI tests on an earlier, larger version of this change). schema.js now reads both forms through one helper and sorts object-form topTerms by descending count before grouping, since JavaScript enumerates integer-like keys first. The upgrade note says so.

AI disclosure: the site classification, the edits, the notes and this description were drafted with Claude Code and reviewed by me.

Tests

No new Java tests: the shape change is the documented intent of this SIP step. Ran the suites covering every changed path: LukeRequestHandlerTest, LukeRequestHandlerDistribTest, MoreLikeThisHandlerTest, MoreLikeThisComponentTest, DistributedMLTComponentTest, DebugComponentTest, DistributedDebugComponentTest, SpellCheckComponentTest, DistributedSpellCheckComponentTest, SignificantTermsQParserPluginTest, TestDistributedGrouping, SolrIndexSplitterTest, SplitByPrefixTest, the rest package and TestJsonFacets: 175 tests, all pass. Plus ./gradlew check -x test.

Coverage gaps, stated plainly: {!igain} and {!tlogit} have no functional tests in solr/core (they are driven by the streaming features/train expressions). The Admin UI browser tests (:solr:webapp:test -Ptests.selenium=true) could not run on my machine because Selenium Manager does not support Linux ARM; the rewritten schema.js parser was checked under Node with both input forms and produces identical structures, and the "Admin UI Tests" workflow should be allowed to run on this PR.

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide
  • I have added a changelog entry for my change

…ions

Luke topTerms/histogram, MoreLikeThis interestingTerms and the SolrCloud
moreLikeThis section, the empty-result debug section, managed-resource
initArgs, the igain/tlogit sections, Core Admin SPLIT details, plus the
internal spellcheck/facet config maps and the grouping shard serializers.
The Admin UI Schema Browser now reads Luke topTerms/histogram in both the
object and the legacy flat-array form.
@github-actions github-actions Bot added documentation Improvements or additions to documentation admin-ui cat:search cat:index cat:schema labels Nov 19, 2026
@github-actions

Copy link
Copy Markdown

Automated PR readiness judgements (LLM-generated; may be wrong; not updated on later pushes).

  • ✅ Jira issue in title: already present
  • ✅ Changelog: type: changed
  • ⚠️ Reference Guide update — missing: The change alters the response format of documented endpoints like Luke, MoreLikeThis, and SearchHandler, which should be reflected in the Reference Guide's documentation of these handlers and the json.​nl parameter behavior.​
  • ✅ Upgrade notes: included
  • ✅ Tests: not needed

interestingTerms changes shape in this PR. The moreLikeThis component
example was already stale: the single-node section has been a
SimpleOrderedMap, rendered as an object, before this change.
NamedList<Integer> topFreq = new NamedList<>();
NamedList<Integer> allFreq = new NamedList<>();
NamedList<Double> analytics = new SimpleOrderedMap<>();
NamedList<Integer> topFreq = new SimpleOrderedMap<>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI text below 🤖

Could we leave docFreq as a NamedList in this slice? The producer adds each term’s real frequency to topFreq, then adds each featured term a second time using allFreq.get(...). Nothing populates allFreq, so that second value is null. The old flat response preserves both entries; the new object writes duplicate properties, and a last-wins parser like JSON.parse returns null for the featured term. If we want to convert this section, could we fix the duplicate-producing code first and add a JSON test that checks the featured term’s frequency?

@isaric isaric Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, and a pre-existing bug: allFreq is never filled, so every featured term gets a second, null entry. Left docFreq as a NamedList in this slice (1d3c635); filed SOLR-18677 for the duplicate entries.

}

NamedList<Integer> list = new NamedList<>();
NamedList<Integer> list = new SimpleOrderedMap<>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI text below 🤖

Could we keep topTerms as a NamedList? The queue holds distinct indexed terms, but the response uses indexedToReadable() as the key. A legacy TrieIntField with multiple precision levels can have several indexed terms that all decode to "0", with different document frequencies. The old flat response keeps each entry. JSON clients parsing the new object can only see one. The histogram can still move to a map independently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed; indexedToReadable() isn't injective for Trie precision terms. topTerms stays a NamedList, histogram moves (1d3c635).

for (var i = 0; i < data.topTerms.length; i += 2) {
var count = data.topTerms[i + 1];
var currentGroup = {count: 0};
var topTerms = namedListEntries(data.topTerms);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI text below 🤖

If the Schema Browser keeps accepting object-form topTerms, could we sort the entries by descending count before grouping them? JavaScript enumerates integer-like keys first, even when Luke emitted them in frequency order. Running this helper in Node with {"alpha":50,"21":30,"omega":30,"4":10} gave count groups 10, 30, 50, 30; the equivalent flat response gave 50, 30, 10, with both 30-count terms together. A mixed numeric/text fixture would cover this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced with your fixture. Added a stable sort by descending count before grouping; both forms now give 50:alpha, 30:21+omega, 10:4 (1d3c635).

* Luke request handler: a field's `histogram` and `topTerms` are objects. The Admin UI's Schema Browser reads both forms.
* MoreLikeThis handler: `interestingTerms` with `mlt.interestingTerms=details` is an object keyed by term.
* MoreLikeThis component in SolrCloud: `moreLikeThis` is an object keyed by document, as it already was on a single node.
* Managed resources (`/schema/analysis/...`): `initArgs` is an object.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI text below 🤖

Could we remove this bullet from the JSON migration list? The built-in managed word-set and synonym GET handlers already return initArgs through buildMapToStore(), which converts it to a map on the base branch too. The Java type changes here, but clients of those endpoints already receive a JSON object. The same correction applies to the changelog.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, buildMapToStore already converts it. Dropped the bullet and the changelog mention; the Java change stays (1d3c635).

…amedList

topTerms keys come from indexedToReadable(), which is not injective for
legacy Trie precision terms, and igain adds each featured term to docFreq a
second time with a null value (allFreq is never populated), so both can
carry repeated keys. The Schema Browser now sorts object-form topTerms by
descending count before grouping, since JavaScript enumerates integer-like
keys first. Managed-resource initArgs was already a map in the response, so
its bullet is dropped from the note and the changelog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants