SOLR-15493: Throw an error message if the feature store doesn't exist #1487
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.
https://issues.apache.org/jira/browse/SOLR-15493
https://issues.apache.org/jira/browse/SOLR-15494
Description
When a wrong/non-existent feature store name is passed to the query for feature extraction, an empty list is returned;
it also happens when inspecting the contents of a non-existent feature store. It would be helpful if a message was returned indicating that the feature store I am calling is not present.
Also, this non-existent (and empty) feature store is inappropriately added to the feature store list and only disappears after the collection is reloaded.
This contribution wants to add the ability to throw an exception when a non-existent feature store name is passed and thus wants to prevent it from being inappropriately added to the feature store list.
Solution
A check for a non-existent feature store was added in the doGet method of the ManagedFeatureStore.java class, throwing a Solr exception.
Also, a getter method of the "stores" variable was added in the ManagedFeatureStore.java class and used to throw the exception during the feature extraction (logging phase) if the passed feature store is missing from the store list.
In this phase, there is the need to differentiate between the two cases where no feature store name is passed (i.e., it is null):
If a reranking query (qr) is not passed, it means the model name is not passed either, so the only feature store that could be used is the default feature store (which should not be empty, otherwise an error is thrown).
On the other hand, if a reranking query is passed, it means that a model name has been specified, so a temporarily empty feature store is created to later add features in the implTransform() method, using the methods of the FeatureLogger class.
Tests
To verify that an Exception is thrown when a non-existent feature store is passed to the query (with fl parameter) 3 tests have been added in solr/modules/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureLogging.java:
To verify that an Exception is thrown when trying to get a missing feature store and that this feature store is not inappropriately added to the feature store list, some tests in solr/modules/ltr/src/test/org/apache/solr/ltr/store/rest/TestModelManagerPersistence.java have been modified.
Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.