tsornin14 opened a new pull request, #4921: URL: https://github.com/apache/solr/pull/4921
https://issues.apache.org/jira/browse/SOLR-18466 <!-- _(If you are a project committer then you may remove some/all of the following template.)_ Before creating a pull request, please file an issue in the ASF Jira system for Solr: * https://issues.apache.org/jira/projects/SOLR For something minor (i.e. that wouldn't be worth putting in release notes), you can skip JIRA. To create a Jira issue, you will need to create an account there first. The title of the PR should reference the Jira issue number in the form: * SOLR-####: <short description of problem or changes> SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on. Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. --> # Description The `search()` function in streaming expressions currently ignores `_route_` for shard selection and queries every active slice of the target collection. Users with known routing keys therefore incur unnecessary request and response overhead, which can be significant on large clusters. This change adds support for `_route_` param in the streaming expression search function, reusing `docCol.getRouter().getSearchSlices()` which is used for shard selection in normal distributed search. # Solution Two files in `solr/solrj-streaming`: 1. **the `CloudSolrStream` class:** the existing method: ```java List<Slice> getSlices( String collectionName, CloudSolrClient cloudSolrClient, boolean checkAlias) ``` is kept for existing calls from `TopicStream`, `TextLogitStream`, `FeaturesSelectionStream`, and `StatementImpl` (all out of scope for this change); these are unaffected and continue to receive all active slices A new overloaded helper method is added: ```java List<Slice> getSlices( String collectionName, CloudSolrClient cloudSolrClient, boolean checkAlias, SolrParams solrParams) ``` When `solrParams` contains a nonempty `_route_`, each collection's slices are resolved via `docCol.getRouter().getSearchSlices(routeKeys, params, docCol)` and when `_route_` is absent (or empty), all active slices are returned exactly as before. 2. **the `TupleStream` class:** `CloudSolrStream.getSlices(collection, cloudSolrClient, true, solrParams)` is called after the request params are assembled and passed to the route aware `getSlices`. **Example usages:** ```text expr=search(collection1, zkHost="localhost:9983", qt="/export", q="*:*", fl="id,a_s,a_i,a_f", sort="a_f asc, a_i asc", _route_="routeKeyA") ``` ```text expr=search(collection1, zkHost="localhost:9983", qt="/export", q="*:*", fl="id,a_s,a_i,a_f", sort="a_f asc, a_i asc", _route_="routeKeyA,routeKeyB,routeKeyC") ``` **One note on backward compatibility:** Previously, `_route_` was ignored during shard selection for streaming expression `search()`. With this change, nonempty route values are passed to `docCol.getRouter().getSearchSlices(routeKeys, params, docCol)`. For collections using the implicit router, an invalid `_route_` value now causes the request to fail. Previously, the same request searched all active shards despite the invalid `_route_`. This should be documented in the release/ upgrade notes. # Tests The following four tests cover single and multiple route keys, composite id routing, missing and empty route values, and invalid implicit router shard names. 1. testCloudSolrStreamWithRouteParam 2. testCloudSolrStreamWithCompositeIdRoute 3. testCloudSolrStreamWithEmptyRoute 4. testCloudSolrStreamWithInvalidRoute # Checklist Please review the following and check all that apply: - [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. - [x] I have created a Jira issue and added the issue ID to my pull request title. - [ ] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation) - [x] I have developed this patch against the `main` branch. - [x] I have run `./gradlew check`. - [x] I have added tests for my changes. - [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide) - [x] I have added a [changelog entry](https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc) for my change -- 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]
