fix: filter exchanges by application and restore snake_case sort columns
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:
@@ -166,6 +166,8 @@ public class OpenSearchIndex implements SearchIndex {
|
|||||||
filter.add(termQuery("agent_id.keyword", request.agentId()));
|
filter.add(termQuery("agent_id.keyword", request.agentId()));
|
||||||
if (request.correlationId() != null)
|
if (request.correlationId() != null)
|
||||||
filter.add(termQuery("correlation_id.keyword", request.correlationId()));
|
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
|
// Full-text search across all fields + nested processor fields
|
||||||
if (request.text() != null && !request.text().isBlank()) {
|
if (request.text() != null && !request.text().isBlank()) {
|
||||||
|
|||||||
@@ -59,6 +59,18 @@ public record SearchRequest(
|
|||||||
"durationMs", "executionId", "applicationName"
|
"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 {
|
public SearchRequest {
|
||||||
if (limit <= 0) limit = DEFAULT_LIMIT;
|
if (limit <= 0) limit = DEFAULT_LIMIT;
|
||||||
if (limit > MAX_LIMIT) limit = MAX_LIMIT;
|
if (limit > MAX_LIMIT) limit = MAX_LIMIT;
|
||||||
@@ -67,12 +79,9 @@ public record SearchRequest(
|
|||||||
if (!"asc".equalsIgnoreCase(sortDir)) sortDir = "desc";
|
if (!"asc".equalsIgnoreCase(sortDir)) sortDir = "desc";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Returns the snake_case column name for OpenSearch/DB ORDER BY. */
|
||||||
* Returns the validated sort field name for OpenSearch ORDER BY.
|
|
||||||
* Field names match the ExecutionDocument record fields (camelCase).
|
|
||||||
*/
|
|
||||||
public String sortColumn() {
|
public String sortColumn() {
|
||||||
return sortField;
|
return SORT_FIELD_TO_COLUMN.getOrDefault(sortField, "start_time");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a copy with resolved agentIds (from application name lookup). */
|
/** Create a copy with resolved agentIds (from application name lookup). */
|
||||||
|
|||||||
Reference in New Issue
Block a user