Skip to content

SOLR-18446: Keep collection routing path-scoped in HttpSolrCall - #5202

Open
nick-boss-tech wants to merge 2 commits into
apache:mainfrom
nick-boss-tech:solr-18446-path-routing-phone-agent-2
Open

nick-boss-tech wants to merge 2 commits into
apache:mainfrom
nick-boss-tech:solr-18446-path-routing-phone-agent-2

Conversation

@nick-boss-tech

@nick-boss-tech nick-boss-tech commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖 (posted on behalf of Nick Shanin)

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

What happens today

When a request carries a collection parameter that disagrees with the collection named in the URL path, HttpSolrCall routes by the parameter, so the request can be served by a collection it was not addressed to.

HttpSolrCall at the base resolves the request's collection with the collection parameter taking precedence over the path. The ticket states the rule this violates: the URL path alone should govern which collection receives a collection-scoped request.

What this change does

The URL path decides the collection, on the v1 and the V2 entry paths alike; the collection parameter no longer overrides the path the request was sent to.

HttpSolrCall.java takes the collection from the path, and V2HttpCall.java now resolves the collection from its path segment instead of the parameter. HttpSolrCallCloudTest covers the v1 disagreement case, the narrowing case, and the V2 disagreement case. Four existing tests that relied on the parameter winning (BasicDistributedZkTest, TestDistribIDF, RuleBasedAuthorizationCoreCollectionTest, DistributedQueryComponentOptimizationTest) now put their collections in the path, and AliasIntegrationTest keeps a case where a CloudSolrClient carries the collection only as a parameter, which the client moves into the path. The Ref Guide's distributed-requests page now describes the parameter as narrowing the path, and the Solr 11 major-changes page records the removal. Eleven files change, including the changelog entry.

Proof

The new V2 coverage failed before its fix and passes at this head; the checks below ran on this exact tree, verified 2026-10-22.

  • Before the V2 fix, the new V2 case failed with expected:<[collection1]> but was:<[collection2]> (the parameter winning on the V2 path); the other four HttpSolrCallCloudTest tests passed.
  • At this head, seed 18446: HttpSolrCallCloudTest 5 run, AliasIntegrationTest 9 run, BasicDistributedZkTest 1 run (its monolithic test, including the multi-collection section), and one multi-collection method each in TestDistribIDF, RuleBasedAuthorizationCoreCollectionTest, and DistributedQueryComponentOptimizationTest: 18 run, 0 skipped, 0 failures.
  • The changelog entry parses, the Error Prone compile passes, and :solr:core:check -x test passes.

Limits

Requests whose parameter matches their path route as before. Three cases change: a parameter that disagrees with the path, a request with no collection in the path, and a multi-collection path with a non-matching parameter.

  • The precedence change is deliberate and is what the ticket asks for. A client that relied on overriding the path with the collection parameter will now be routed by the path.
  • A request with no collection segment in the path, such as /solr/select?collection=c1, now returns 404 instead of routing by the parameter.
  • When the path names several collections (an alias or a comma list), the parameter only narrows the list; a parameter that matches none of them is ignored and the request goes to all of them.

Changelog: changelog/unreleased/SOLR-18446-path-controls-collection-routing.yml

AI-generated description. Nick Shanin directed the work and takes responsibility for this contribution.

nick-boss-tech added a commit to nick-boss-tech/solr that referenced this pull request Oct 23, 2026
@nick-boss-tech
nick-boss-tech marked this pull request as ready for review October 23, 2026 05:09
nick-boss-tech added a commit to nick-boss-tech/solr that referenced this pull request Oct 23, 2026
String collectionStr = queryParams.get(COLLECTION_PROP, origCorename);
collectionsList =
resolveCollectionListOrAlias(collectionStr); // &collection= takes precedence
String collectionStr = origCorename;

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.

I suppose teh collectionStr sort of better conveys the werid remapping of what looks like a core to a collection.

I wonder, is there a better name than origCorename that would somehow convey that we cover both core and collection? Maybe I have seen coreOrCollection ?

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.

🤖 AI text below 🤖 (reviewed by Nick Shanin)

The rename to coreOrCollection is in 1c0a942ff8. It covers the field in HttpSolrCall and its uses in V2HttpCall, with no behavior change.

SolrQuery query = new SolrQuery("*:*");
query.set("collection", "collection2,collection3");
long found = clients.get(0).query(query).getResults().getNumFound();
long found = clients.get(0).query("collection2,collection3", query).getResults().getNumFound();

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.

interesting, so I can just put in the path multiple collections comma delimited... how not restful is that? or is that okay? If it was a concept we supported, well, there are bunch of APIs that might benefit by "comma dellimited list in a path param"... s

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.

🤖 AI text below 🤖 (reviewed by Nick Shanin)

Yes, v1 distributed queries already support comma-separated collections or an alias in the path. Jan describes both on SOLR-18446, and David confirms that comma-delimited support came from the time-routed-alias work and should stay. This PR keeps that support; the collection parameter can narrow the path's collections but cannot override them.

The collection named in the URL path governs which collections a query runs against.
To query several collections at once, name them in the path, as a comma-separated list or through an alias; the features of Solr which work in a distributed manner will work across those collections.

The `collection` parameter can only narrow the set named in the path.

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.

if we are dropping the use of the collection parameter? Which I think it what we ant to be doing right? Then we don't need to document it or show it.

Or, are we deprecating the "collection" parameter and changing it's behavior?

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.

🤖 AI text below 🤖 (reviewed by Nick Shanin)

Neither dropped nor deprecated. The parameter no longer selects collections on its own; it can only narrow the set named in the path. The page now documents that narrower role, and the example is corrected to show narrowing: /solr/collection1,collection2,collection3/select?collection=collection2.

A node started this way asks the Overseer to re-run its node prioritization, so a preferred node takes over without waiting for the current Overseer to restart.
Note that node roles are fixed for the lifetime of a node: unlike `ADDROLE`, they cannot be changed on a running node.

=== `collection` Parameter No Longer Routes Requests

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.

so I guess I am slightly unclear, it feels to me like the collection parameter is no longer needed?

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.

🤖 AI text below 🤖 (reviewed by Nick Shanin)

It is optional, but still useful for narrowing a v1 request whose path names several collections or an alias. For example, /solr/collection1,collection2/select?collection=collection2 selects only collection2. The entry means the parameter can no longer override the path, rather than that it has been removed.

@epugh
epugh requested a review from dsmiley October 23, 2026 10:54
@epugh

epugh commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Put some comments in, but I htink I need @dsmiley to weigh in....

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants