gpt4 book ai didi

elasticsearch - 如何在ElasticSearch中获取倒排索引的大小

转载 作者:行者123 更新时间:2023-12-02 22:41:42 33 4
gpt4 key购买 nike

我认为标题是不言自明的。据我所知 indices-stats 仅返回集合中文档的数量,而不返回 token /术语的数量。

编辑:

以下是有关我的索引的更多信息;它包含用以下映射索引的医学出版物:

{
u'papers': {
u'properties': {
u'article_abstract': {
u'type':
u'string'
},
u'article_sections': {
u'type':
u'string'
},
u'article_text': {
u'type':
u'string'
},
u'article_title': {
u'type':
u'string'
},
u'keyword_group': {
u'type':
u'string'
},
u'references': {
u'type':
u'string'
}
}
}
}

我正在寻找一种获取索引中所有字段中 唯一术语数量的方法。

最佳答案

可以从相同indices-stats api的store字段中获取索引的文件大小,例如
{ "docs": { "count": 1886, "deleted": 1557 }, "store": { "size_in_bytes": 519544594, "throttle_time_in_millis": 0 }, ...(skipped)
但是,如果您想要索引的总 token 量,我认为不存在这样的api,因为它意义不大。如果您想要数字,我认为您需要使用script_fieldaggregation进行计算。

编辑:

根据您的架构, token 计数可以如下计算:

{
"query" : {
"match_all" : { }
},
"aggs" : {
"summation" : { "sum" : { "script" : "doc['article_abstract'].values.length+doc['article_sections'].values.length" } }
}
}

如上所示,上面的查询仅计算字段“article_abstracts”和“article_sections”的 token 大小。我不确定是否有任何方法不能“重复”所有字段。但是无论如何,您可以从此继续。

关于elasticsearch - 如何在ElasticSearch中获取倒排索引的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25596982/

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