1
bucket_selector과 유사한 작업을 수행하지만 숫자 척도 대신 키 일치를 기반으로 테스트하는 방법이 있는지 알고 싶습니다.집계의 탄성 검색 집계
데이터 샘플 :
좀 더 컨텍스트를 제공하기 위해, 여기 내 사용 사례입니다[
{
"@version": "1",
"@timestamp": "2017-04-27T04:28:23.589Z",
"type": "json",
"headers": {
"message": {
"type": "requestactivation"
}
},
"id": "668"
},
{
"@version": "1",
"@timestamp": "2017-04-27T04:32:23.589Z",
"type": "json",
"headers": {
"message": {
"type": "requestactivation"
}
},
"id": "669"
},
{
"@version": "1",
"@timestamp": "2017-04-27T04:30:00.802Z",
"type": "json",
"headers": {
"message": {
"type": "activationrequested"
}
},
"id": "668"
}
]
내가 마지막 이벤트 유형 requestactivation
의 모든 ID를 검색하고 싶습니다.
{
"size": 0,
"query": {
"bool": {
"filter": [
{
"exists": {
"field": "id"
}
},
{
"terms": {
"headers.message.type": [
"requestactivation",
"activationrequested"
]
}
}
]
}
},
"aggs": {
"id": {
"terms": {
"field": "id",
"size": 10000
},
"aggs": {
"latest": {
"max": {
"field": "@timestamp"
}
},
"hmtype": {
"terms": {
"field": "headers.message.type",
"size": 1
}
}
}
}
}
}
:
가 이미 아이디, 당 마지막 이벤트 유형을 검색하는 집계를 가지고 있지만 내가 여기에 키
에 따라 버킷을 필터링하는 방법을 생각하지 않은 쿼리입니다
모든 매핑 분석되지{
"took": 5,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 0,
"hits": []
},
"aggregations": {
"id": {
"doc_count_error_upper_bound": 3,
"sum_other_doc_count": 46,
"buckets": [
{
"key": "986",
"doc_count": 4,
"hmtype": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 2,
"buckets": [
{
"key": "activationrequested",
"doc_count": 2
}
]
},
"latest": {
"value": 1493238253603,
"value_as_string": "2017-04-26T20:24:13.603Z"
}
},
{
"key": "967",
"doc_count": 2,
"hmtype": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 1,
"buckets": [
{
"key": "requestactivation",
"doc_count": 1
}
]
},
"latest": {
"value": 1493191161242,
"value_as_string": "2017-04-26T07:19:21.242Z"
}
},
{
"key": "554",
"doc_count": 7,
"hmtype": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 5,
"buckets": [
{
"key": "requestactivation",
"doc_count": 5
}
]
},
"latest": {
"value": 1493200196871,
"value_as_string": "2017-04-26T09:49:56.871Z"
}
}
]
}
}
}
(키워드) : 다음은 결과 샘플입니다.
목표는 버킷의 키가 "요청 활성화"인 경우에만 결과를 줄이는 것입니다.
id에 대해 activationrequest가 두 번 이상 나타날 수 있으므로 문서 수를 사용할 수 없습니다.
최근에 집계가 시작되었으므로 질문이 명확한 것처럼 보일 뿐이므로 예제가이 특정 논리와 일치하지 않는 것으로 보입니다.
내가 끝 포함 이벤트가 "activationrequested"(예를 들어, 나는 실제로 "requestactivation"을 찾고있다.) ID를 가지고 있는지 여부에 관계없이 다른 유형의 이벤트가 있는지 여부에 관계없이 모든 ID를 사용한다. – Olivier
나의 나쁜 것, 그것은 "include"이어야한다 : "requestactivation"'...하지만 나는 약간의 제한이 있다는 느낌이있다. –
그러나 include는 기본적으로 쿼리에서 activationrequested ** 이벤트 **를 필터링 한 것과 같은 방식으로 작동합니다 (말하면 쿼리 히트는 신경 쓰지 않습니다). 반면에 ** 인증 요청을받은 ** ID를 필터링하고 싶습니다. – Olivier