elasticsearch 在弹性体中搜索多个索引时,限制每个索引的大小
我一直遵循这篇文章的指导方针。我可以获得所需的输出,但在相同的DSL中,如何限制每个索引的结果大小elasticsearch 在弹性体中搜索多个索引时,限制每个索引的大小,elasticsearch,nest,elasticsearch,Nest,我一直遵循这篇文章的指导方针。我可以获得所需的输出,但在相同的DSL中,如何限制每个索引的结果大小 对于给定的查询,您可以使用聚合来分组和限制每个索引的点击数(在本例中,限制为5): 非常感谢。有没有一种方法不输出树根的“点击数”,而只输出聚合?我想这就是为什么大小为0以从结果文档中去除“点击数”的原因。是的,这就是原因。对不起,我没有强调这一点,但最后你自己发现了:) POST http://localhost:9200/componenttypeindex%2Cprojecttypeind
对于给定的查询,您可以使用聚合来分组和限制每个索引的点击数(在本例中,限制为5):
非常感谢。有没有一种方法不输出树根的“点击数”,而只输出聚合?我想这就是为什么大小为0以从结果文档中去除“点击数”的原因。是的,这就是原因。对不起,我没有强调这一点,但最后你自己发现了:)
POST http://localhost:9200/componenttypeindex%2Cprojecttypeindex/Componenttype%2CProjecttype/_search?pretty=true&typed_keys=true
{
"query": {
"bool": {
"should": [
{
"bool": {
"filter": [
{
"term": {
"_index": {
"value": "componenttypeindex"
}
}
}
],
"must": [
{
"multi_match": {
"fields": [
"Componentname",
"Summary^1.1"
],
"operator": "or",
"query": "test"
}
}
]
}
},
{
"bool": {
"filter": [
{
"term": {
"_index": {
"value": "projecttypeindex"
}
}
}
],
"must": [
{
"multi_match": {
"fields": [
"Projectname",
"Summary^0.3"
],
"operator": "or",
"query": "test"
}
}
]
}
}
]
}
}
}
{
"size": 0,
"query": {
... Same query as above ...
},
"aggs": {
"index_agg": {
"terms": {
"field": "_index",
"size": 20
},
"aggs": {
"hits_per_index": {
"top_hits": {
"size": 5
}
}
}
}
}
}