Skip to content

Commit ae9d422

Browse files
author
Srikanth Padakanti
committed
Address the PR comments
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
1 parent ecafcf4 commit ae9d422

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -661,13 +661,19 @@ private void fetch(TermsLookup termsLookup, Client client, ActionListener<List<O
661661
}
662662

663663
for (SearchHit hit : hits) {
664-
Map<String, Object> sourceAsMap = hit.getSourceAsMap();
665-
if (sourceAsMap != null) {
666-
List<Object> extractedValues = XContentMapValues.extractRawValues(
667-
termsLookup.path(),
668-
sourceAsMap
669-
);
670-
terms.addAll(extractedValues);
664+
if (termsLookup.store()) {
665+
if (hit.field(termsLookup.path()) != null) {
666+
terms.addAll(hit.field(termsLookup.path()).getValues());
667+
}
668+
} else {
669+
Map<String, Object> sourceAsMap = hit.getSourceAsMap();
670+
if (sourceAsMap != null) {
671+
List<Object> extractedValues = XContentMapValues.extractRawValues(
672+
termsLookup.path(),
673+
sourceAsMap
674+
);
675+
terms.addAll(extractedValues);
676+
}
671677
}
672678
}
673679
delegatedListener.onResponse(terms);

0 commit comments

Comments
 (0)