Skip to content

Commit

Permalink
Change the version check to current to pass bwc test.
Browse files Browse the repository at this point in the history
Signed-off-by: conggguan <congguan@amazon.com>
  • Loading branch information
conggguan committed Apr 26, 2024
1 parent 37646cb commit cacbdab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public class NeuralSparseTwoPhaseParameters implements Writeable {
static final ParseField PRUNING_RATIO = new ParseField("pruning_ratio");
@VisibleForTesting
static final ParseField ENABLED = new ParseField("enabled");
private static final Version MINIMAL_SUPPORTED_VERSION_TWO_PHASE_SEARCH = Version.V_2_14_0;

private static final Version MINIMAL_SUPPORTED_VERSION_TWO_PHASE_SEARCH = Version.CURRENT;
private Float window_size_expansion;
private Float pruning_ratio;
private Boolean enabled;
Expand Down Expand Up @@ -82,6 +81,7 @@ public static void initialize(final ClusterService clusterService, final Setting
);
clusterService.getClusterSettings()
.addSettingsUpdateConsumer(NeuralSearchSettings.NEURAL_SPARSE_TWO_PHASE_MAX_WINDOW_SIZE, it -> MAX_WINDOW_SIZE = it);

}

public static NeuralSparseTwoPhaseParameters getDefaultSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public class NeuralSparseTwoPhaseUtil {
*/
public static void addRescoreContextFromNeuralSparseQuery(final Query query, final SearchContext searchContext) {
Map<NeuralSparseQuery, Float> neuralSparseQuery2Weight = new HashMap<>();
// Store all neuralSparse query and it's global weight in neuralSparseQuery2Weight, and get the max windowSizeExpansion of them..
// Store all neuralSparse query with global weight in neuralSparseQuery2Weight, and get the max windowSizeExpansion of them.
float windowSizeExpansion = populateQueryWeightsMapAndGetWindowSizeExpansion(query, neuralSparseQuery2Weight, 1.0f, 1.0f);
Query twoPhaseQuery = getNestedTwoPhaseQueryFromNeuralSparseQuerySet(neuralSparseQuery2Weight);
if (twoPhaseQuery == null) return;
// Set the valid neural_sparse query's current query to it's highScoreTokenQuery.
neuralSparseQuery2Weight.keySet().forEach(NeuralSparseQuery::setCurrentQueryToHighScoreTokenQuery);
// Add two phase to searchContext's rescore list.
addTwoPhaseQuery2RescoreContext(searchContext, windowSizeExpansion, twoPhaseQuery);
addTwoPhaseQueryRescoreContext(searchContext, windowSizeExpansion, twoPhaseQuery);
}

private static float populateQueryWeightsMapAndGetWindowSizeExpansion(
Expand Down Expand Up @@ -83,7 +83,7 @@ private static float getOriginQueryWeightAfterRescore(final List<RescoreContext>
.reduce(1.0f, (a, b) -> a * b);
}

private static void addTwoPhaseQuery2RescoreContext(
private static void addTwoPhaseQueryRescoreContext(
final SearchContext searchContext,
final float windowSizeExpansion,
Query twoPhaseQuery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ public void initialize(final ClusterService clusterService) {
public Version getClusterMinVersion() {
return this.clusterService.state().getNodes().getMinNodeVersion();
}

}

0 comments on commit cacbdab

Please sign in to comment.