gpt4 book ai didi

elasticsearch - 在Elasticsearch中检索词条查询

转载 作者:行者123 更新时间:2023-12-02 22:24:30 25 4
gpt4 key购买 nike

我正在使用Elasticsearch 1.1.0并尝试检索名为text的字段中的前10个术语

我尝试了以下操作,但是它返回了所有文档:

{
"query": {
"match_all": {}
},
"facets": {
"text": {
"terms": {
"field": "text",
"size": 10
}
}
}
}

编辑

以下是返回结果的示例:
    {
"took": 2,
"timed_out": false,
"_shards": {


"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2747,
"max_score": 1,
"hits": [
{
"_index": "index_name",
"_type": "type_name",
"_id": "621637640908050432",
"_score": 1,
"_source": {
"metadata": {
"result_type": "recent",
"iso_language_code": "en"
},
"in_reply_to_status_id_str": null,
"in_reply_to_status_id": null,
"created_at": "Thu Jul 16 11:08:57 +0000 2015",
.
.
.
.

我究竟做错了什么?

谢谢。

最佳答案

试试这个:

GET /index_name/type_name/_search?search_type=count
{
"query": {
"match_all": {}
},
"facets": {
"text": {
"terms": {
"field": "text",
"size": 10
}
}
}
}

关于elasticsearch - 在Elasticsearch中检索词条查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33408827/

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