我最近开始通过 Python API 使用 Elasticsearch,并尝试使用术语向量在一组文档中获取每个单词的频率。
我正在使用多个 Multi termvectors API,如下所示:
results = es.mtermvectors(index=INDEX_NAME, doc_type=DOC_TYPE, ids="1,2",
fields=['text'],
field_statistics=True,
term_statistics=True)
但是,这会为每个文档返回一组单独的结果,而我正在尝试获取所有文档的总结果。term_statistics/doc_freq 值(“包含当前术语的文档数”)应该给我我需要的信息,但这始终是 1,因为每个文档都会返回单独的结果。有什么想法可以让 doc_freq 返回有意义的值吗?我需要使用聚合吗?
这里的相关文档:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors .html http://elasticsearch-py.readthedocs.io/en/master/api.html
提前感谢您的帮助。