Elasticsearch专题精讲—— REST APIs —— Document APIs —— Multi term vectors API

REST APIs —— Document APIs —— Multi term vectors API

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/docs-multi-termvectors.html

Retrieves multiple term vectors with a single request.

检索具有单个请求的多个 term(词项)向量。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
curl -X POST "localhost:9200/_mtermvectors?pretty" -H 'Content-Type: application/json' -d'
        {
           "docs": [
              {
                 "_index": "my-index-000001",
                 "_id": "2",
                 "term_statistics": true
              },
              {
                 "_index": "my-index-000001",
                 "_id": "1",
                 "fields": [
                    "message"
                 ]
              }
           ]
        }'

1、Request(请求)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/docs-multi-termvectors.html#docs-multi-termvectors-api-request

1
2
3
POST /_mtermvectors
 
POST /< index>/_mtermvectors

2、Prerequisites(先决条件)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/docs-multi-termvectors.html#docs-multi-termvectors-api-prereqs

If the Elasticsearch security features are enabled, you must have the read index privilege for the target index or index alias.

如果启用了 Elasticsearch 安全特性,则必须拥有目标索引或索引别名的读索引特权。

3、Description(描述)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/docs-multi-termvectors.html#docs-multi-termvectors-api-desc

You can specify existing documents by index and ID or provide artificial documents in the body of the request. You can specify the index in the request body or request URI.

您可以通过索引和 ID 指定现有文档,或者在请求体中提供人工文档。可以在请求体或请求 URI 中指定索引。

The response contains a docs array with all the fetched termvectors. Each element has the structure provided by the termvectors API.

响应包含一个 docs 数组,其中包含所有获取的术语向量。每个元素都有 termvectors(https://www.elastic.co/guide/en/elasticsearch/reference/8.8/docs-termvectors.html) API 提供的结构。

See the termvectors API for more information about the information that can be included in the response.

有关可以包含在响应中的信息的更多信息,请参见 term vectors API(向量 API)(https://www.elastic.co/guide/en/elasticsearch/reference/8.8/docs-termvectors.html)。

4、Example(例子)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/docs-multi-termvectors.html#docs-multi-termvectors-api-example

If you specify an index in the request URI, the index does not need to be specified for each documents in the request body:

如果在请求URI中指定了索引,那么在请求正文中的每个文档都不需要指定索引。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
curl -X POST "localhost:9200/my-index-000001/_mtermvectors?pretty" -H 'Content-Type: application/json' -d'
{
   "docs": [
      {
         "_id": "2",
         "fields": [
            "message"
         ],
         "term_statistics": true
      },
      {
         "_id": "1"
      }
   ]
}'

If all requested documents are in same index and the parameters are the same, you can use the following simplified syntax:

如果所有请求的文档都在同一个索引中,并且参数相同,则可以使用以下简化语法:

1
2
3
4
5
6
7
8
9
10
curl -X POST "localhost:9200/my-index-000001/_mtermvectors?pretty" -H 'Content-Type: application/json' -d'
{
  "ids": [ "1", "2" ],
  "parameters": {
    "fields": [
      "message"
    ],
    "term_statistics": true
  }
}'

5、Artificial documents(人工文档)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/docs-multi-termvectors.html#docs-multi-termvectors-artificial-doc

You can also use mtermvectors to generate term vectors for artificial documents provided in the body of the request. The mapping used is determined by the specified _index.

您还可以使用 mtermvectors 为请求正文中提供的人工文档生成 term vectors(词项向量)。使用的映射由指定的 _index 确定。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
curl -X POST "localhost:9200/_mtermvectors?pretty" -H 'Content-Type: application/json' -d'
{
   "docs": [
      {
         "_index": "my-index-000001",
         "doc" : {
            "message" : "test test test"
         }
      },
      {
         "_index": "my-index-000001",
         "doc" : {
           "message" : "Another test ..."
         }
      }
   ]
}'
posted @   左扬  阅读(13)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2022-06-13 Kubernetes——Pod资源使用资源注解(annotation)
2022-06-13 Kubernetes——Pod镜像及其获取策略
2022-06-13 Kubernetes——分布式系统设计中几种容器运行模型
2022-06-13 Kubernetes——spec和status字段
levels of contents
点击右上角即可分享
微信分享提示