1
使用Spring Data ES
。 LocalDateTime
パラメータに等しい私はちょうど前に船の位置を検索したい入れ子オブジェクト日付フィールドによるSpringデータESクエリ
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.time.LocalDateTime;
public class ShipLocation {
private double latitude;
private double longitude;
@Temporal(TemporalType.TIMESTAMP)
private LocalDateTime recordedOnTime;
//setters and getters
}
か:
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
@Document(indexName = "ship", type = "journey")
public class ShipJourney {
@Id
private String shipId;
@Field(type = FieldType.Nested)
private List<ShipLocation> shipLocation;
//getters and setters
}
ShipLocation
のように定義されたネストされたオブジェクトです:
私は、次の定義とship
という名前のインデックスを持っています。
私はこの試みた:私だけが唯一の原因shipId's
一意に最終的に一つのレコードになりますどのShipJourney
自体にTop
を使用していたことを後で実現するために
ShipJourney findTopByShipIdAndShipLocationRecordedOnTimeLessThanOrderByShipLocationRecordedOnTimeDesc(
String shipId, LocalDateTime recordedOnTime);
を。
ネストされた要素の属性を属性に基づいて取得する方法を制限するにはどうすればよいですか。
このレポメソッド名は非常にストーリーです。私を覚えてますか? –