私が持っている3つのtables.Their構造のような -は適用することにより、ネストされたフィールドからのデータは、弾性検索に問い合わせる必要があり得る
public class RcItem{
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "rcItem")
@JsonManagedReference
private Set<RcItemRegulation> rcItemRegulations = new HashSet<>();
}
public class RcItemRegulation{
@ManyToOne
@JoinColumn(name = "rc_item_id")
@Field(type = FieldType.Nested, index = FieldIndex.analyzed, analyzer = "lowercase_keyword", store = true)
@JsonBackReference
private RcItem rcItem;
@ManyToOne
@JoinColumn(name = "rgltn_id")
@Field(type = FieldType.Nested, index = FieldIndex.analyzed, analyzer = "lowercase_keyword", store = true)
private Regulation regulation;
}
public class Regulation{
@OneToMany(cascade = CascadeType.ALL, mappedBy = "regulation")
@JsonManagedReference
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<RcItemRegulation> rcItemRegulations = new HashSet<>();
@Column(name = "rgltn_full_name")
@Field(type = FieldType.String, index = FieldIndex.analyzed, analyzer = "lowercase_keyword", store = true)
private String rgltnFullName;
}
のように私のデータ構造内でこの上のデータインデックス - このため
"rcItemRegulations": [
{
"id": 1,
"rcItemRgltnType": "primary",
"regulation": {
"rgltnFullName": "17 ABC § 1.12(f)(5)(i)(B)"
}
}]
私は弾性検索クエリを試してみます -
{"query":{
"bool" : {
"must" : {
"bool" : {
"must" : [ {
"term" : {
"rcItemRegulations.rcItemRgltnType" : "primary"
}
}, {
"term" : {
"rcItemRegulations.regulation.rgltnFullName" : "17 ABC § 1.12(f)(5)(i)(B)"
}
} ]
}
}
}
}
}
これが存在する場合でも空白の結果配列を返します.Gを助けてください弾性検索からのデータ。
あなたは 'ネスト'と 'パス'を使用する必要があります。この例を確認してください。 https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-query.html – pvpkiran