私は理解できない非常に奇妙な問題やバグがあります。私は子供(コース) - 親(カレッジ)関係を持っています。私は特定の大学に属しているコースを照会しますが、これはうまく動作します。私のアプリケーションのコンセプトのために、私はまた、特定の大学に属し、その結果を集計するコースを持っている大学を照会する必要があります。私は別の集計のためにこのコンセプトを使用していますが、私にとって意味をなさないこの1つのケースを除いてすべて正常に動作します。注意してください:私は2つのタイプがあります - カレッジとコース - とタイプコースはまた、ネストされたオブジェクトを持っています。これは、親集約がESでサポートされていないため、特定の集約を行うことができるように組み込まれています。このコンセプトは私のためにはうまくいきますし、言及された問題/バグとは関係がないとは思いません。Term idというネストされたフィールドのフィルタが期待どおりに動作しない
事前のおかげで、ハンネス
マッピング(縮小):
types:
college:
mappings:
id: ~
premium: { "type": "boolean" }
boost: { "type": "boolean" }
course:
mappings:
_all: { "analyzer": "text" }
id: { "type": "string", "analyzer": "term" }
name: { "type": "string", "analyzer": "text" }
types: { "type": "string", "analyzer": "term" }
college:
type: "object"
properties:
id: { "type": "string", "analyzer": "term" }
name: { "type": "string", "analyzer": "text" }
_parent:
type: "college"
問合せ:
GET _search
{
"query": {
"function_score": {
"query": {
"has_child": {
"type": "course",
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"terms": {
"college.id": [
"371"
]
}
}
]
}
}
}
}
}
}
}
},
"aggs": {
"children": {
"children": {
"type": "course"
},
"aggs": {
"filtered": {
"filter": {
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"terms": {
"college.id": [
"371"
]
}
}
]
}
}
}
}
},
"aggs": {
"abschluss": {
"terms": {
"field": "degree",
"size": 0
},
"aggs": {
"unique": {
"cardinality": {
"field": "_parent",
"precision_threshold": 500
}
}
}
},
"coursecount": {
"terms": {
"field": "_parent",
"size": 0
}
}
}
}
}
}
},
"from": 0,
"size": 20
}
結果:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "studiengaenge_dev",
"_type": "college",
"_id": "371",
"_score": 1,
"_source": {
"id": "371",
"premium": true,
"boost": null
}
}
]
},
"aggregations": {
"children": {
"doc_count": 15,
"filtered": {
"doc_count": 0,
"coursecount": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": []
},
"abschluss": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": []
}
}
}
}
}
あなたが実行しているESのバージョン? – Val
私はES 1.7.2を実行しています – HKandulla
"id"フィールドの名前を "collegeId"に変更すると、クエリは期待通りに機能します。おそらく、ESで予約されている名前idは、用語フィルタで使用できません。私は未回答として質問を残すが、これはdefinetely私のために働く.. – HKandulla