Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-15493: Throw an error message if the feature store doesn't exist #1487

Merged
merged 1 commit into from
Apr 24, 2023

Conversation

ilariapet
Copy link
Contributor

@ilariapet ilariapet commented Mar 23, 2023

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:

  • featureExtraction_NonExistentFeatureStore_shouldThrowException
  • featureExtraction_NonExistentFeatureStoreReRanking_shouldThrowException
  • featureExtraction_NoFeatureAndModelStore_shouldThrowException

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:

  • 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)
  • 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

Copy link
Contributor

@alessandrobenedetti alessandrobenedetti left a comment

Choose a reason for hiding this comment

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

Some minor to review

@alessandrobenedetti alessandrobenedetti merged commit 69800fd into apache:main Apr 24, 2023
3 checks passed
@ilariapet ilariapet deleted the jira/SOLR-15493 branch April 27, 2023 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants