Skip to content

Commit

Permalink
Invert feature flag meaning, disable feature by default
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
  • Loading branch information
martin-gaievski committed Jul 13, 2023
1 parent c1356cf commit 2617ca4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public class NeuralSearch extends Plugin implements ActionPlugin, SearchPlugin,
* We need to write and read by the value, key is only for definition
*/
@VisibleForTesting
public static final Pair<String, String> NEURAL_SEARCH_HYBRID_SEARCH_ENABLED = Pair.of(
"neural_search_hybrid_search_enabled",
String.join(".", TransportSettings.FEATURE_PREFIX, "neural_search_hybrid_search_enabled")
public static final Pair<String, String> NEURAL_SEARCH_HYBRID_SEARCH_DISABLED = Pair.of(
"neural_search_hybrid_search_disabled",
String.join(".", TransportSettings.FEATURE_PREFIX, "neural_search_hybrid_search_disabled")
);
private MLCommonsClientAccessor clientAccessor;

Expand Down Expand Up @@ -97,14 +97,14 @@ public Map<String, Processor.Factory> getProcessors(Processor.Parameters paramet

@Override
public Optional<QueryPhaseSearcher> getQueryPhaseSearcher() {
if (FeatureFlags.isEnabled(NEURAL_SEARCH_HYBRID_SEARCH_ENABLED.getValue())) {
return Optional.of(new HybridQueryPhaseSearcher());
if (FeatureFlags.isEnabled(NEURAL_SEARCH_HYBRID_SEARCH_DISABLED.getValue())) {
return Optional.empty();
}
return Optional.empty();
return Optional.of(new HybridQueryPhaseSearcher());
}

@Override
protected Optional<String> getFeature() {
return Optional.of(NEURAL_SEARCH_HYBRID_SEARCH_ENABLED.getKey());
return Optional.of(NEURAL_SEARCH_HYBRID_SEARCH_DISABLED.getKey());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package org.opensearch.neuralsearch.plugin;

import static org.mockito.Mockito.mock;
import static org.opensearch.neuralsearch.plugin.NeuralSearch.NEURAL_SEARCH_HYBRID_SEARCH_ENABLED;
import static org.opensearch.neuralsearch.plugin.NeuralSearch.NEURAL_SEARCH_HYBRID_SEARCH_DISABLED;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -42,15 +42,15 @@ public void testQueryPhaseSearcher() {
assertNotNull(queryPhaseSearcher);
assertTrue(queryPhaseSearcher.isEmpty());

System.setProperty(NEURAL_SEARCH_HYBRID_SEARCH_ENABLED.getValue(), "true");
System.setProperty(NEURAL_SEARCH_HYBRID_SEARCH_DISABLED.getValue(), "true");

Optional<QueryPhaseSearcher> queryPhaseSearcherWithFeatureFlagDisabled = plugin.getQueryPhaseSearcher();

assertNotNull(queryPhaseSearcherWithFeatureFlagDisabled);
assertFalse(queryPhaseSearcherWithFeatureFlagDisabled.isEmpty());
assertTrue(queryPhaseSearcherWithFeatureFlagDisabled.get() instanceof HybridQueryPhaseSearcher);

System.setProperty(NEURAL_SEARCH_HYBRID_SEARCH_ENABLED.getValue(), "");
System.setProperty(NEURAL_SEARCH_HYBRID_SEARCH_DISABLED.getValue(), "");
}

public void testProcessors() {
Expand All @@ -66,6 +66,6 @@ public void testFeature() {
Optional<String> feature = plugin.getFeature();
assertNotNull(feature);
assertFalse(feature.isEmpty());
assertEquals(NEURAL_SEARCH_HYBRID_SEARCH_ENABLED.getKey(), feature.get());
assertEquals(NEURAL_SEARCH_HYBRID_SEARCH_DISABLED.getKey(), feature.get());
}
}

0 comments on commit 2617ca4

Please sign in to comment.