fix: support all sortable columns and use camelCase for OpenSearch
All checks were successful
CI / build (push) Successful in 1m24s
CI / cleanup-branch (push) Has been skipped
CI / docker (push) Successful in 45s
CI / deploy (push) Successful in 37s
CI / deploy-feature (push) Has been skipped

Add executionId and applicationName to allowed sort fields. Fix sort
column mapping to use camelCase field names matching the OpenSearch
ExecutionDocument fields instead of snake_case DB column names. This
was causing sorts on most columns to either silently fall back to
startTime or return empty results from OpenSearch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-03-24 17:36:51 +01:00
parent 53e9073dca
commit cdbe330c47

View File

@@ -55,16 +55,8 @@ public record SearchRequest(
private static final int MAX_LIMIT = 500;
private static final java.util.Set<String> ALLOWED_SORT_FIELDS = java.util.Set.of(
"startTime", "status", "agentId", "routeId", "correlationId", "durationMs"
);
private static final java.util.Map<String, String> SORT_FIELD_TO_COLUMN = java.util.Map.of(
"startTime", "start_time",
"status", "status",
"agentId", "agent_id",
"routeId", "route_id",
"correlationId", "correlation_id",
"durationMs", "duration_ms"
"startTime", "status", "agentId", "routeId", "correlationId",
"durationMs", "executionId", "applicationName"
);
public SearchRequest {
@@ -75,9 +67,12 @@ public record SearchRequest(
if (!"asc".equalsIgnoreCase(sortDir)) sortDir = "desc";
}
/** Returns the validated database column name for ORDER BY. */
/**
* Returns the validated sort field name for OpenSearch ORDER BY.
* Field names match the ExecutionDocument record fields (camelCase).
*/
public String sortColumn() {
return SORT_FIELD_TO_COLUMN.getOrDefault(sortField, "start_time");
return sortField;
}
/** Create a copy with resolved agentIds (from application name lookup). */