-
Notifications
You must be signed in to change notification settings - Fork 128
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
Set additional settings at index level for knn enabled indexes #738
Closed
martin-gaievski
wants to merge
2
commits into
opensearch-project:main
from
martin-gaievski:index-specific-plugin-settings
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/test/java/org/opensearch/knn/plugin/KNNPluginTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.plugin; | ||
|
||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.index.IndexModule; | ||
import org.opensearch.index.shard.IndexSettingProvider; | ||
import org.opensearch.knn.KNNTestCase; | ||
import org.opensearch.knn.index.util.KNNEngine; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
public class KNNPluginTests extends KNNTestCase { | ||
|
||
private static final String INDEX_NAME = "test_index"; | ||
|
||
public void testMMapFileExtensionsForHybridFs() { | ||
final KNNPlugin knnPlugin = new KNNPlugin(); | ||
|
||
final Collection<IndexSettingProvider> additionalIndexSettingProviders = knnPlugin.getAdditionalIndexSettingProviders(); | ||
|
||
assertEquals(1, additionalIndexSettingProviders.size()); | ||
|
||
final IndexSettingProvider indexSettingProvider = additionalIndexSettingProviders.iterator().next(); | ||
// settings for knn enabled index | ||
final Settings knnIndexSettings = indexSettingProvider.getAdditionalIndexSettings(INDEX_NAME, false, getKnnDefaultIndexSettings()); | ||
final List<String> mmapFileExtensionsForHybridFsKnnIndex = knnIndexSettings.getAsList( | ||
IndexModule.INDEX_STORE_HYBRID_MMAP_EXTENSIONS.getKey() | ||
); | ||
|
||
assertNotNull(mmapFileExtensionsForHybridFsKnnIndex); | ||
assertFalse(mmapFileExtensionsForHybridFsKnnIndex.isEmpty()); | ||
|
||
for (KNNEngine engine : KNNEngine.values()) { | ||
assertTrue(mmapFileExtensionsForHybridFsKnnIndex.containsAll(engine.mmapFileExtensions())); | ||
} | ||
|
||
// settings for index without knn | ||
final Settings nonKnnIndexSettings = indexSettingProvider.getAdditionalIndexSettings(INDEX_NAME, false, getNonKnnIndexSettings()); | ||
final List<String> mmapFileExtensionsForHybridFsNonKnnIndex = nonKnnIndexSettings.getAsList( | ||
IndexModule.INDEX_STORE_HYBRID_MMAP_EXTENSIONS.getKey() | ||
); | ||
|
||
assertNotNull(mmapFileExtensionsForHybridFsNonKnnIndex); | ||
assertTrue(mmapFileExtensionsForHybridFsNonKnnIndex.isEmpty()); | ||
} | ||
|
||
private Settings getKnnDefaultIndexSettings() { | ||
return Settings.builder().put("number_of_shards", 1).put("number_of_replicas", 0).put("index.knn", true).build(); | ||
} | ||
|
||
private Settings getNonKnnIndexSettings() { | ||
return Settings.builder().put("number_of_shards", 1).put("number_of_replicas", 0).build(); | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to keep it for cluster level as well for indices that upgrade or were created on an old version of the cluster?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not required as we apply the setting in the code, it's not persisted. Also if customer used custom index-level overwrites that will apply to 2.6 as well. Customer values should overwrite both cluster defaults and index provided by the plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but assume that a customer did not apply any override. On 2.5, by default, their index with use vex/vec in the setting because we apply the cluster override. However, in 2.6, if no cluster override is provided, the index will not use vex/vec in the setting. So this could be an unexpected degradation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked with quick bwc test, indexes from 2.5 do not have index level setting when opened in 2.6, setting is stored along with the index and doesn't apply on index or shard opening as I was initially thinking.