我有一组280万个文档,其中包含我使用ElasticSearch查询的标记集,但其中许多文档可以通过一个ID组合在一起.我想使用标签查询我的数据,然后通过重复的ID聚合它们.我的搜索结果通常有成千上万的文档,但我只想汇总前100个搜索结果.如何将聚合仅限制为查询的前100个结果?
我正在尝试在弹性搜索中进行存储桶聚合,该搜索仅在从查询返回的结果上运行。
似乎聚合在每次点击时运行,但只返回其中的一部分。这很好,但问题是从聚合返回的文档与从查询返回的文档不匹配。
这是映射:
LOCATION_MAPPING = {
id: { type: 'long' },
name: { type: 'text' },
street: { type: 'text' },
city: { type: 'text' },
state: { type: 'text' },
zip: { type: 'text' },
price: { type: 'text' },
geolocation: { type: 'geo_point' },
amenities: { type: 'nested' },
reviews: { type: 'nested' },
};
Run Code Online (Sandbox Code Playgroud)
这是查询:
{
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"query": {
"bool": {
"filter": {
"geo_distance": {
"distance": "1000yd",
"geolocation": …Run Code Online (Sandbox Code Playgroud)