fix: filter exchanges by application and restore snake_case sort columns
All checks were successful
CI / build (push) Successful in 1m23s
CI / cleanup-branch (push) Has been skipped
CI / docker (push) Successful in 41s
CI / deploy (push) Successful in 39s
CI / deploy-feature (push) Has been skipped

Add application_name filter to OpenSearch query builder — sidebar
app selection now correctly filters the exchange list. The
application field was being resolved to agentIds in the controller
but never applied as a query filter in OpenSearch.

Also restore snake_case sort column mapping since the OpenSearch
toMap() serializer uses snake_case field names (start_time, route_id,
etc.), not camelCase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-03-24 17:41:07 +01:00
parent cdbe330c47
commit b7cac68ee1
2 changed files with 16 additions and 5 deletions

View File

@@ -166,6 +166,8 @@ public class OpenSearchIndex implements SearchIndex {
filter.add(termQuery("agent_id.keyword", request.agentId()));
if (request.correlationId() != null)
filter.add(termQuery("correlation_id.keyword", request.correlationId()));
if (request.application() != null && !request.application().isBlank())
filter.add(termQuery("application_name.keyword", request.application()));
// Full-text search across all fields + nested processor fields
if (request.text() != null && !request.text().isBlank()) {

View File

@@ -59,6 +59,18 @@ public record SearchRequest(
"durationMs", "executionId", "applicationName"
);
/** Maps camelCase API sort field names to snake_case OpenSearch/DB column names. */
private static final java.util.Map<String, String> SORT_FIELD_TO_COLUMN = java.util.Map.ofEntries(
java.util.Map.entry("startTime", "start_time"),
java.util.Map.entry("status", "status"),
java.util.Map.entry("agentId", "agent_id"),
java.util.Map.entry("routeId", "route_id"),
java.util.Map.entry("correlationId", "correlation_id"),
java.util.Map.entry("durationMs", "duration_ms"),
java.util.Map.entry("executionId", "execution_id"),
java.util.Map.entry("applicationName", "application_name")
);
public SearchRequest {
if (limit <= 0) limit = DEFAULT_LIMIT;
if (limit > MAX_LIMIT) limit = MAX_LIMIT;
@@ -67,12 +79,9 @@ public record SearchRequest(
if (!"asc".equalsIgnoreCase(sortDir)) sortDir = "desc";
}
/**
* Returns the validated sort field name for OpenSearch ORDER BY.
* Field names match the ExecutionDocument record fields (camelCase).
*/
/** Returns the snake_case column name for OpenSearch/DB ORDER BY. */
public String sortColumn() {
return sortField;
return SORT_FIELD_TO_COLUMN.getOrDefault(sortField, "start_time");
}
/** Create a copy with resolved agentIds (from application name lookup). */