I'm quite new to elasticsearch and spring-data combo.
Let me give you some background. I started from this entity
@Document(indexName = "my-entity")
public class MyEntity {
@Id
private String id;
private String someField;
}
A few of them got created and indexed. Later on, I added a new field to the entity. Now it looks like this:
@Document(indexName = "my-entity")
public class MyEntity {
@Id
private String id;
private String someField;
@Field(type = FieldType.Date, format = DateFormat.date_time)
private Date date;
}
What I'm trying to achieve is to return all entities sorted by my new field (which not all existing entities have).
Initially I've adjust my Repository and define something similar to List<MyEntity> findAllByOrderByDate();, but when I try to call it, I get the following exception:
"No mapping found for [date] in order to sort on"
I am aware that a possible solution would be to make use of ignore_unmapped option from elasticsearch, but my question is: how do I achieve this with spring-data-elasticsearch?
On the other hand, I'm not fixed up on using the Repository approach - I'm open for solutions.
Thank you!