Lütfen aşağıdaki etki alanı üzerinde toplanacak veya geçerli API'da bulunmadığını kanıtlayacak bir mekanizma bulmam için bana yardımcı olun.Elasticsearch içinde geri planlanmış toplamalara katılın
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, belirli üniversitelerden kaç kişinin mezun olduğuyla ilgili istatistikleri bulmak için ES'yi nasıl sorgulayabilir?
Bir olasılık buldum ama kontaklara göre yukarıdaki soruya cevap veremez çünkü bana istenilen sonucu vermez, ama sadece kendi özel profiller (iç içe dokümanlar) ne:
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
}
} ]
}
}
}
Ama burada bir irtibat aynı veya farklı doc (ana) olup olmadığını sırasıyla benim ilk soruya cevap veremez, emin olamaz:
bana verir ne.
Önerileriniz için teşekkür ederiz.
ilk öneri basitçe çalışmaz. İkinci seçenek işe yarayabilir, ancak ne yazık ki benim durumumda değil, çünkü dokümana yerleştirilmiş dokümanlar var ve bir tür has_parent toplaması yapmaya çalışıyorum. Şimdilik http://stackoverflow.com/questions/35061945/match-query-inside-script-elasticsearch. Yine de teşekkürler – Serj