Skip to content

Commit

Permalink
Incorporating changes from main
Browse files Browse the repository at this point in the history
Signed-off-by: Vacha Shah <[email protected]>
  • Loading branch information
VachaShah committed Feb 8, 2024
1 parent 5085c50 commit 3cac405
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class FeatureFlags {
* Gates the optimization to enable bloom filters for doc id lookup.
*/
public static final String DOC_ID_FUZZY_SET = "opensearch.experimental.optimize_doc_id_lookup.fuzzy_set.enabled";

/**
* Gates the functionality of integrating protobuf within search API and node-to-node communication.
*/
Expand Down Expand Up @@ -122,6 +122,6 @@ public static boolean isEnabled(Setting<Boolean> featureFlag) {
);

public static final Setting<Boolean> DOC_ID_FUZZY_SET_SETTING = Setting.boolSetting(DOC_ID_FUZZY_SET, false, Property.NodeScope);

public static final Setting<Boolean> PROTOBUF_SETTING = Setting.boolSetting(PROTOBUF, false, Property.NodeScope, Property.Dynamic);
}
15 changes: 14 additions & 1 deletion server/src/main/java/org/opensearch/search/SearchHit.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,20 @@ public SearchHit(byte[] in) throws IOException {
});
this.sortValues = new SearchSortValues(this.searchHitProto.getSortValues().toByteArray());
if (this.searchHitProto.getMatchedQueriesCount() > 0) {
this.matchedQueries = this.searchHitProto.getMatchedQueriesList().toArray(new String[0]);
this.matchedQueries = new LinkedHashMap<>(this.searchHitProto.getMatchedQueriesCount());
for (String query : this.searchHitProto.getMatchedQueriesList()) {
matchedQueries.put(query, Float.NaN);
}
}
if (this.searchHitProto.getMatchedQueriesWithScoresCount() > 0) {
Map<String, Float> tempMap = this.searchHitProto.getMatchedQueriesWithScoresMap()
.entrySet()
.stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()));
this.matchedQueries = tempMap.entrySet()
.stream()
.sorted(Map.Entry.comparingByKey())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new));
}
if (this.searchHitProto.hasExplanation()) {
this.explanation = readExplanation(this.searchHitProto.getExplanation().toByteArray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ message SearchHit {
optional string index = 16;
optional string clusterAlias = 17;
map<string, SearchHits> innerHits = 18;
map<string, float> matchedQueriesWithScores = 19;

message NestedIdentity {
optional string field = 1;
Expand Down

0 comments on commit 3cac405

Please sign in to comment.