fix: query both top-level and MDC exchangeId for log search
Existing log records only have exchangeId inside the mdc object, not as a top-level indexed field. Use a bool should clause to match on either exchangeId (new records) or mdc.camel.exchangeId (old records). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -110,7 +110,11 @@ public class OpenSearchLogIndex {
|
||||
bool.must(Query.of(q -> q.term(t -> t.field("agentId").value(FieldValue.of(agentId)))));
|
||||
}
|
||||
if (exchangeId != null && !exchangeId.isEmpty()) {
|
||||
bool.must(Query.of(q -> q.term(t -> t.field("exchangeId").value(FieldValue.of(exchangeId)))));
|
||||
// Match on top-level field (new records) or MDC nested field (old records)
|
||||
bool.must(Query.of(q -> q.bool(b -> b
|
||||
.should(Query.of(s -> s.term(t -> t.field("exchangeId").value(FieldValue.of(exchangeId)))))
|
||||
.should(Query.of(s -> s.term(t -> t.field("mdc.camel.exchangeId").value(FieldValue.of(exchangeId)))))
|
||||
.minimumShouldMatch("1"))));
|
||||
}
|
||||
if (level != null && !level.isEmpty()) {
|
||||
bool.must(Query.of(q -> q.term(t -> t.field("level").value(FieldValue.of(level.toUpperCase())))));
|
||||
|
||||
Reference in New Issue
Block a user