Description
Hello guys!
First and foremost, thanks for this awesome addition to the Spring ecosystem! I have a problem, though:
Here's an excerpt from an Elasticsearch document:
{
"loglevel": "TRACE",
"monitoring_event": {
"type": "foo",
"transaction_id": "baz",
"monitoring_datetime": "2025-03-04T15:39:45.144"
}
}
Here's my Java POJO for this document:
@Data
@Document(indexName = "foo-index")
public class FooEvent
{
@Id
private String id;
@Field(name = "monitoring_event", type = FieldType.Object)
private MonitoringEvent monitoringEvent;
@Field("loglevel", type = FieldType.Keyword)
private String loglevel;
}
@Data
class MonitoringEvent {
@Field(name = "type", type = FieldType.Keyword)
private String type;
@Field(name = "transaction_id", type = FieldType.Keyword)
private String transactionId;
@Field(name = "monitoring_datetime", type = FieldType.Date, format = strict_date_optional_time_nanos)
private LocalDateTime monitoringDatetime;
)
Here's my repository:
public interface FooRepository extends ElasticsearchRepository<FooEvent, String> {
List<FooEvent> findByMonitoringEvent_TransactionIdOrderByMonitoringEvent_monitoringDatetime(String transactionId);
}
When invoking the method, the following error occurs: No mapping found for [monitoringEvent.monitoringDatetime] in order to sort on
. So the problem is around the OrderBy
clause of the repo method.
The sort clause of the underlying REST query is: "sort":[{"monitoringEvent.monitoringDatetime":{"mode":"min","order":"asc"}}]
The error is that monitoringEvent
does not exist in Elasticsearch document, only monitoring_event
. Am I doing something wrong (missing config, annotation, etc), or it is indeed a bug? The sort param should be in the same form as at the annotated @Field
name parameter, so, in this case, monitoring_event.monitoring_datetime
.
Thanks in advance for any replies.
regards,
Daniel