forked from opensearch-project/neural-search
-
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.
Adds method_parameters in neural search query to support ef_search (o…
…pensearch-project#787) (opensearch-project#814) (opensearch-project#818) Signed-off-by: Tejas Shah <[email protected]> (cherry picked from commit dea1fe3) Co-authored-by: Tejas Shah <[email protected]>
- Loading branch information
1 parent
3bbd63a
commit 33bed19
Showing
15 changed files
with
194 additions
and
56 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
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
50 changes: 50 additions & 0 deletions
50
src/main/java/org/opensearch/neuralsearch/common/MinClusterVersionUtil.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,50 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.opensearch.neuralsearch.common; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import org.opensearch.Version; | ||
import org.opensearch.knn.index.IndexUtil; | ||
import org.opensearch.neuralsearch.util.NeuralSearchClusterUtil; | ||
|
||
import java.util.Map; | ||
|
||
import static org.opensearch.knn.index.query.KNNQueryBuilder.MAX_DISTANCE_FIELD; | ||
import static org.opensearch.knn.index.query.KNNQueryBuilder.MIN_SCORE_FIELD; | ||
import static org.opensearch.neuralsearch.query.NeuralQueryBuilder.MODEL_ID_FIELD; | ||
|
||
/** | ||
* A util class which holds the logic to determine the min version supported by the request parameters | ||
*/ | ||
public final class MinClusterVersionUtil { | ||
|
||
private static final Version MINIMAL_SUPPORTED_VERSION_DEFAULT_MODEL_ID = Version.V_2_11_0; | ||
private static final Version MINIMAL_SUPPORTED_VERSION_RADIAL_SEARCH = Version.V_2_14_0; | ||
|
||
// Note this minimal version will act as a override | ||
private static final Map<String, Version> MINIMAL_VERSION_NEURAL = ImmutableMap.<String, Version>builder() | ||
.put(MODEL_ID_FIELD.getPreferredName(), MINIMAL_SUPPORTED_VERSION_DEFAULT_MODEL_ID) | ||
.put(MAX_DISTANCE_FIELD.getPreferredName(), MINIMAL_SUPPORTED_VERSION_RADIAL_SEARCH) | ||
.put(MIN_SCORE_FIELD.getPreferredName(), MINIMAL_SUPPORTED_VERSION_RADIAL_SEARCH) | ||
.build(); | ||
|
||
public static boolean isClusterOnOrAfterMinReqVersionForDefaultModelIdSupport() { | ||
return NeuralSearchClusterUtil.instance().getClusterMinVersion().onOrAfter(MINIMAL_SUPPORTED_VERSION_DEFAULT_MODEL_ID); | ||
} | ||
|
||
public static boolean isClusterOnOrAfterMinReqVersionForRadialSearch() { | ||
return NeuralSearchClusterUtil.instance().getClusterMinVersion().onOrAfter(MINIMAL_SUPPORTED_VERSION_RADIAL_SEARCH); | ||
} | ||
|
||
public static boolean isClusterOnOrAfterMinReqVersion(String key) { | ||
Version version; | ||
if (MINIMAL_VERSION_NEURAL.containsKey(key)) { | ||
version = MINIMAL_VERSION_NEURAL.get(key); | ||
} else { | ||
version = IndexUtil.minimalRequiredVersionMap.get(key); | ||
} | ||
return NeuralSearchClusterUtil.instance().getClusterMinVersion().onOrAfter(version); | ||
} | ||
} |
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.