次のドメインに集約するメカニズムを見つけたり、現在のAPIに存在しないことを証明してください。Elasticsearchのreverse_nested集約の結合
curl -XDELETE 127.0.0.1:9200/test_index
curl -XPUT 127.0.0.1:9200/test_index -d '{
"mappings": {
"contact": {
"properties": {
"facebook_profile": {
"type": "nested",
"properties": {
"education": {
"type": "string"
},
"year": {
"type": "integer"
}
}
},
"google_profile": {
"type": "nested",
"properties": {
"education": {
"type": "string"
},
"year": {
"type": "integer"
}
}
}
}
}
}
}'
curl -XPUT 127.0.0.1:9200/test_index/contact/contact1 -d '{
"google_profile": {
"education": "stanford", "year": 1990
}
}'
curl -XPUT 127.0.0.1:9200/test_index/contact/contact2 -d '
{
"facebook_profile": {
"education": "stanford", "year": 1990
}
}'
特定の大学を卒業した連絡先の数について統計情報を検索するにはどのようにしてESをクエリできますか?
は、私は一つの可能性を見つけたが、それは接点に関して上記の質問に答えることができないので、それは、私に必要な結果を与えるものではありませんが、唯一の彼らの特定のプロファイル(ネストされたドキュメント)へ:
curl -XPOST '127.0.0.1:9200/test_index/_search?search_type=count&pretty=true' -d '{
"aggs": {
"facebook_educations": {
"aggs": {
"field": {
"terms": {
"field": "contact.facebook_profile.education"
},
"aggs": {
"reverse": {
"reverse_nested": {
}
}
}
}
},
"nested": {
"path": "contact.facebook_profile"
}
},
"google_educations": {
"aggs": {
"field": {
"terms": {
"field": "contact.google_profile.education"
},
"aggs": {
"reverse": {
"reverse_nested": {
}
}
}
}
},
"nested": {
"path": "contact.google_profile"
}
}
}
}'
"aggregations" : {
"facebook_educations" : {
"doc_count" : 1,
"field" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [ {
"key" : "stanford",
"doc_count" : 1,
"reverse" : {
"doc_count" : 1
}
} ]
}
},
"google_educations" : {
"doc_count" : 1,
"field" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [ {
"key" : "stanford",
"doc_count" : 1,
"reverse" : {
"doc_count" : 1
}
} ]
}
}
}
しかし、ここに私は1つの見つかった接触がDOC(親)は、同一でも異なっている場合、それぞれ、私は私の最初の質問に答えることができないことを確認することはできません。私に与えるもの
。
ありがとうございました。
あなたの最初の提案は、単に、動作しません。 2番目のオプションはうまくいくかもしれませんが、残念なことに私のケースでは、子ドキュメントにラップされたネストされたドキュメントがあり、何らかの種類のhas_parent集約を実行しようとしています。これは私が今持っているものですhttp://stackoverflow.com/questions/35061945/match-query-inside-script-elasticsearch。とにかくありがとうございました – Serj