gpt4 book ai didi

Elasticsearch-获取给定字段的所有值?

转载 作者:行者123 更新时间:2023-11-29 02:43:00 25 4
gpt4 key购买 nike

是否可以查询特定字段的所有值?假设我有“文章”并且每篇文章都有一个作者,我可以执行查询来查找所有作者的列表吗?

最佳答案

How to get all possible values for field author?

curl -XGET  http://localhost:9200/articles/_search?pretty -d '
{
"aggs" : {
"whatever_you_like_here" : {
"terms" : { "field" : "author", "size":10000 }
}
},
"size" : 0
}'

注意

  • "size":10000 最多获取 10000 个唯一值。默认为 10。

  • "size":0 默认情况下,"hits" 包含 10 个文档。我们不需要它们。

  • 默认情况下,存储桶按 doc_count 降序排列。


引用:bucket terms aggregation

另请注意,根据 this page , facets 已被 Elasticsearch 1.0 中的聚合所取代,聚合是 facets 的超集。

关于Elasticsearch-获取给定字段的所有值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14384736/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com