forked from opensearch-project/k-NN
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed the default values for ef_search and ef_constrction for enabl…
…ing better indexing and search latency for vector search Signed-off-by: Navneet Verma <[email protected]>
- Loading branch information
Showing
26 changed files
with
354 additions
and
96 deletions.
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
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
48 changes: 48 additions & 0 deletions
48
src/main/java/org/opensearch/knn/index/KNNIndexSettingProvider.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,48 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
package org.opensearch.knn.index; | ||
|
||
import lombok.NoArgsConstructor; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.index.shard.IndexSettingProvider; | ||
|
||
@NoArgsConstructor | ||
public class KNNIndexSettingProvider implements IndexSettingProvider { | ||
|
||
private static final Settings EF_SEARCH_SETTING = Settings.builder() | ||
.put(KNNSettings.KNN_ALGO_PARAM_EF_SEARCH, KNNSettings.INDEX_KNN_DEFAULT_ALGO_PARAM_EF_SEARCH) | ||
.build(); | ||
|
||
/** | ||
* Returns explicitly set default index {@link Settings} for the given index. This should not | ||
* return null. | ||
* | ||
* @param indexName {@link String} name of the index | ||
* @param isDataStreamIndex boolean: index is a datastream index or not | ||
* @param templateAndRequestSettings {@link Settings} | ||
*/ | ||
@Override | ||
public Settings getAdditionalIndexSettings(String indexName, boolean isDataStreamIndex, Settings templateAndRequestSettings) { | ||
if (isKNNIndex(templateAndRequestSettings) && isEfSearchNotSetByUser(templateAndRequestSettings)) { | ||
return EF_SEARCH_SETTING; | ||
} | ||
return IndexSettingProvider.super.getAdditionalIndexSettings(indexName, isDataStreamIndex, templateAndRequestSettings); | ||
} | ||
|
||
private boolean isKNNIndex(Settings templateAndRequestSettings) { | ||
return templateAndRequestSettings.getAsBoolean(KNNSettings.KNN_INDEX, false); | ||
} | ||
|
||
private boolean isEfSearchNotSetByUser(Settings templateAndRequestSettings) { | ||
return templateAndRequestSettings.hasValue(KNNSettings.KNN_ALGO_PARAM_EF_SEARCH) == false; | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.