Связано с упругим поиском.У меня есть несколько эластичных поисковых запросов в списке, и я хочу выполнить все запросы параллельно, и моя цель - получить один ответ на все запросы, выполненные параллельно, присутствующие в списке.список выглядит так:
[{
"bool" : {
"filter" : [ {
"bool" : {
"filter" : [ {
"term" : {
"scan.access_level" : "public"
}
}, {
"bool" : {
"should" : [ {
"term" : {
"container.id" : "qa-develop-3c8ffb06-387d-44fd-806b-b54b544a1946"
}
}, {
"term" : {
"container.container_id" : "3c8ffb06-387d-44fd-806b-b54b544a1946"
}
}, {
"term" : {
"container.uuid" : "3c8ffb06-387d-44fd-806b-b54b544a1946"
}
} ],
"minimum_should_match" : "1"
}
} ],
"must_not" : [ {
"bool" : {
"should" : {
"terms" : {
"plugin.id" : [ 3, 7, 15 ]
}
},
"minimum_should_match" : "1"
}
}, {
"term" : {
"host.tracked" : "false"
}
}, {
"term" : {
"tracking.state" : "FIXED"
}
}, {
"term" : {
"modification" : "accepted"
}
}, {
"terms" : {
"severity" : [ 0 ]
}
} ]
}
}, {
"bool" : {
"should" : [ {
"range" : {
"tracking.last_found" : {
"from" : "now-10d/d",
"to" : "now-1d/d",
"include_lower" : true,
"include_upper" : true
}
}
}, {
"range" : {
"tracking.last_fixed" : {
"from" : "now-10d/d",
"to" : "now-1d/d",
"include_lower" : true,
"include_upper" : true
}
}
}, {
"bool" : {
"filter" : {
"range" : {
"scan.started_at" : {
"from" : "now-10d/d",
"to" : "now-1d/d",
"include_lower" : true,
"include_upper" : true
}
}
},
"must_not" : {
"exists" : {
"field" : "tracking"
}
}
}
} ],
"minimum_should_match" : "1"
}
} ]
}
}, {
"bool" : {
"filter" : [ {
"bool" : {
"filter" : [ {
"term" : {
"scan.access_level" : "public"
}
}, {
"bool" : {
"should" : [ {
"term" : {
"container.id" : "qa-develop-3c8ffb06-387d-44fd-806b-b54b544a1946"
}
}, {
"term" : {
"container.container_id" : "3c8ffb06-387d-44fd-806b-b54b544a1946"
}
}, {
"term" : {
"container.uuid" : "3c8ffb06-387d-44fd-806b-b54b544a1946"
}
} ],
"minimum_should_match" : "1"
}
} ],
"must_not" : [ {
"bool" : {
"should" : {
"terms" : {
"plugin.id" : [ 3, 7, 15 ]
}
},
"minimum_should_match" : "1"
}
}, {
"term" : {
"host.tracked" : "false"
}
}, {
"term" : {
"tracking.state" : "FIXED"
}
}, {
"term" : {
"modification" : "accepted"
}
}, {
"terms" : {
"severity" : [ 0 ]
}
} ]
}
}, {
"bool" : {
"should" : [ {
"range" : {
"tracking.last_found" : {
"from" : "now-30d/d",
"to" : "now-21d/d",
"include_lower" : true,
"include_upper" : true
}
}
}, {
"range" : {
"tracking.last_fixed" : {
"from" : "now-30d/d",
"to" : "now-21d/d",
"include_lower" : true,
"include_upper" : true
}
}
}, {
"bool" : {
"filter" : {
"range" : {
"scan.started_at" : {
"from" : "now-30d/d",
"to" : "now-21d/d",
"include_lower" : true,
"include_upper" : true
}
}
},
"must_not" : {
"exists" : {
"field" : "tracking"
}
}
}
} ],
"minimum_should_match" : "1"
}
} ]
}
}, {
"bool" : {
"filter" : [ {
"bool" : {
"filter" : [ {
"term" : {
"scan.access_level" : "public"
}
}, {
"bool" : {
"should" : [ {
"term" : {
"container.id" : "qa-develop-3c8ffb06-387d-44fd-806b-b54b544a1946"
}
}, {
"term" : {
"container.container_id" : "3c8ffb06-387d-44fd-806b-b54b544a1946"
}
}, {
"term" : {
"container.uuid" : "3c8ffb06-387d-44fd-806b-b54b544a1946"
}
} ],
"minimum_should_match" : "1"
}
} ],
"must_not" : [ {
"bool" : {
"should" : {
"terms" : {
"plugin.id" : [ 3, 7, 15 ]
}
},
"minimum_should_match" : "1"
}
}, {
"term" : {
"host.tracked" : "false"
}
}, {
"term" : {
"tracking.state" : "FIXED"
}
}, {
"term" : {
"modification" : "accepted"
}
}, {
"terms" : {
"severity" : [ 0 ]
}
} ]
}
}, {
"bool" : {
"should" : [ {
"range" : {
"tracking.last_found" : {
"from" : "now-20d/d",
"to" : "now-11d/d",
"include_lower" : true,
"include_upper" : true
}
}
}, {
"range" : {
"tracking.last_fixed" : {
"from" : "now-20d/d",
"to" : "now-11d/d",
"include_lower" : true,
"include_upper" : true
}
}
}, {
"bool" : {
"filter" : {
"range" : {
"scan.started_at" : {
"from" : "now-20d/d",
"to" : "now-11d/d",
"include_lower" : true,
"include_upper" : true
}
}
},
"must_not" : {
"exists" : {
"field" : "tracking"
}
}
}
} ],
"minimum_should_match" : "1"
}
} ]
}
}]
Используемая здесь конечная точка упругого поиска - _search
, и я хочу получить один совокупный ответ на все эти три запроса, представленные в этом списке.
код, который я использую для получения ответа:
static ElasticsearchQueryResponse<Map<String, Object>> queryEs(ElasticsearchClient esClient, String queryPath, QueryBuilder query,
List<AbstractAggregationBuilder> aggregations, String metricName, boolean addPrefix = true,
int numFilteredTGMembers = 0) {
String aggString = aggregations.collect { XContentHelper.toString(it)[1..-2] }
.join(", ")
SearchSourceBuilder search = new SearchSourceBuilder()
.size(0)
.query(query)
.aggregations("{$aggString}".bytes)
log.debug("elasticsearch_search ${queryPath}=${search}")
ElasticsearchQueryResponse res = esClient.performQuery(queryPath, search, mapTypeReference, addPrefix, metricName)
log.info("es query filtering on ${numFilteredTGMembers} target group members took ${res.took} ms ")
return res
}
это возвращает один ответ на один запрос, мне нужен агрегированный ответ на все запросы.Пожалуйста, помогите мне в этом.