Skip to content

Commit 5239f68

Browse files
committed
Add query type to shape and extensive unit tests
Signed-off-by: Siddhant Deshmukh <deshsid@amazon.com>
1 parent f89eb88 commit 5239f68

File tree

6 files changed

+920
-101
lines changed

6 files changed

+920
-101
lines changed

src/main/java/org/opensearch/plugin/insights/core/listener/QueryInsightsListener.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public final class QueryInsightsListener extends SearchRequestOperationsListener
5858
private final ClusterService clusterService;
5959
private boolean groupingFieldNameEnabled;
6060
private boolean groupingFieldTypeEnabled;
61+
private final QueryShapeGenerator queryShapeGenerator;
6162

6263
/**
6364
* Constructor for QueryInsightsListener
@@ -87,6 +88,7 @@ public QueryInsightsListener(
8788
super(initiallyEnabled);
8889
this.clusterService = clusterService;
8990
this.queryInsightsService = queryInsightsService;
91+
this.queryShapeGenerator = new QueryShapeGenerator(clusterService);
9092

9193
// Setting endpoints set up for top n queries, including enabling top n queries, window size, and top n size
9294
// Expected metricTypes are Latency, CPU, and Memory.
@@ -271,7 +273,12 @@ private void constructSearchQueryRecord(final SearchPhaseContext context, final
271273
attributes.put(Attribute.TASK_RESOURCE_USAGES, tasksResourceUsages);
272274

273275
if (queryInsightsService.isGroupingEnabled()) {
274-
String hashcode = QueryShapeGenerator.getShapeHashCodeAsString(request.source(), groupingFieldNameEnabled);
276+
String hashcode = queryShapeGenerator.getShapeHashCodeAsString(
277+
request.source(),
278+
groupingFieldNameEnabled,
279+
groupingFieldTypeEnabled,
280+
searchRequestContext.getSuccessfulSearchShardIndices()
281+
);
275282
attributes.put(Attribute.QUERY_HASHCODE, hashcode);
276283
}
277284

0 commit comments

Comments
 (0)