Skip to content

Commit 55bc3e1

Browse files
OAK-11614: ES StatisticalFacets: log search request on timeout (#2194)
1 parent 49716cb commit 55bc3e1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/async/facets/ElasticStatisticalFacetAsyncProvider.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public class ElasticStatisticalFacetAsyncProvider implements ElasticFacetProvide
6565
private final Map<String, List<FulltextIndex.Facet>> allFacets = new HashMap<>();
6666
private final Map<String, Map<String, Integer>> accessibleFacetCounts = new ConcurrentHashMap<>();
6767
private Map<String, List<FulltextIndex.Facet>> facets;
68+
private final SearchRequest searchRequest;
6869
private final CountDownLatch latch = new CountDownLatch(1);
6970
private int sampled;
7071
private long totalHits;
@@ -79,7 +80,7 @@ public class ElasticStatisticalFacetAsyncProvider implements ElasticFacetProvide
7980
map(ElasticIndexUtils::fieldName).
8081
collect(Collectors.toSet());
8182

82-
SearchRequest searchRequest = SearchRequest.of(srb -> srb.index(indexDefinition.getIndexAlias())
83+
this.searchRequest = SearchRequest.of(srb -> srb.index(indexDefinition.getIndexAlias())
8384
.trackTotalHits(thb -> thb.enabled(true))
8485
.source(SourceConfig.of(scf -> scf.filter(ff -> ff.includes(FieldNames.PATH).includes(new ArrayList<>(facetFields)))))
8586
.query(Query.of(qb -> qb.bool(elasticRequestHandler.baseQueryBuilder().build())))
@@ -101,7 +102,7 @@ public class ElasticStatisticalFacetAsyncProvider implements ElasticFacetProvide
101102
searchFuture.whenCompleteAsync((searchResponse, throwable) -> {
102103
try {
103104
if (throwable != null) {
104-
LOG.error("Error while retrieving sample documents", throwable);
105+
LOG.error("Error while retrieving sample documents. Search request: {}", searchRequest, throwable);
105106
} else {
106107
List<Hit<ObjectNode>> searchHits = searchResponse.hits().hits();
107108
this.sampled = searchHits != null ? searchHits.size() : 0;
@@ -124,6 +125,7 @@ public List<FulltextIndex.Facet> getFacets(int numberOfFacets, String columnName
124125
try {
125126
boolean completed = latch.await(15, TimeUnit.SECONDS);
126127
if (!completed) {
128+
LOG.error("Timed out while waiting for facets. Search request: {}", searchRequest);
127129
throw new IllegalStateException("Timed out while waiting for facets");
128130
}
129131
} catch (InterruptedException e) {

0 commit comments

Comments
 (0)