Skip to content

Commit f0a7e9d

Browse files
committed
Add more logging statements to debug failures in search queries
1 parent 98ef9ef commit f0a7e9d

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

server/src/main/java/org/opensearch/search/fetch/FetchPhase.java

+25-4
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
import org.opensearch.index.mapper.NumberFieldMapper;
8080
import org.opensearch.index.mapper.ObjectMapper;
8181
import org.opensearch.index.mapper.SourceFieldMapper;
82-
import org.opensearch.index.recovery.RemoteStoreRestoreService;
8382
import org.opensearch.index.shard.IndexShard;
8483
import org.opensearch.search.DocValueFormat;
8584
import org.opensearch.search.SearchContextSourcePrinter;
@@ -382,6 +381,13 @@ private HitContext prepareNonNestedHitContext(
382381
}
383382
} catch (Exception e) {
384383
logger.error("Error while building source from doc values", e);
384+
logger.info("Original Source : \n");
385+
try {
386+
Map<String, Object> originalSource = XContentHelper.convertToMap(fieldsVisitor.source(), false).v2();
387+
originalSource.forEach((k, v) -> logger.info("{ " + k + " : " + v.toString() + " }"));
388+
} catch (Exception ex) {
389+
logger.error("Error while logging original source values", ex);
390+
}
385391
}
386392
//}
387393
return hitContext;
@@ -465,7 +471,12 @@ private static Map<String, Object> buildUsingDocValues(int docId, LeafReader rea
465471
int size = doubleValues.docValueCount();
466472
double[] vals = new double[size];
467473
for (int i = 0; i < size; i++) {
468-
vals[i] = doubleValues.nextValue();
474+
try {
475+
vals[i] = doubleValues.nextValue();
476+
} catch (Exception e) {
477+
logger.info("Exception while reading value from SNDV\nDoc Id : " + docId + ", DocValueCountSize : " + size + ", i : " + i);
478+
throw e;
479+
}
469480
}
470481
if (size > 1) {
471482
docValues.put(fieldName, vals);
@@ -481,7 +492,12 @@ private static Map<String, Object> buildUsingDocValues(int docId, LeafReader rea
481492
int size = sndv.docValueCount();
482493
long[] vals = new long[size];
483494
for (int i = 0; i < size; i++) {
484-
vals[i] = sndv.nextValue();
495+
try {
496+
vals[i] = sndv.nextValue();
497+
} catch (Exception e) {
498+
logger.info("Exception while reading value from SNDV\nDoc Id : " + docId + ", DocValueCountSize : " + size + ", i : " + i);
499+
throw e;
500+
}
485501
}
486502
if (size > 1) {
487503
docValues.put(fieldName, vals);
@@ -496,7 +512,12 @@ private static Map<String, Object> buildUsingDocValues(int docId, LeafReader rea
496512
int size = sndv.docValueCount();
497513
String[] vals = new String[size];
498514
for (int i = 0; i < size; i++) {
499-
vals[i] = dateFormatter.formatMillis(sndv.nextValue());
515+
try {
516+
vals[i] = dateFormatter.formatMillis(sndv.nextValue());
517+
} catch (Exception e) {
518+
logger.info("Exception while reading value from SNDV\nDoc Id : " + docId + ", DocValueCountSize : " + size + ", i : " + i);
519+
throw e;
520+
}
500521
}
501522
if (size > 1) {
502523
docValues.put(fieldName, vals);

0 commit comments

Comments
 (0)