Ingest Attachment Processor Plugin 是一个文本抽取插件,本质上是利用了 Elasticsearch的ingest node功能,提供了关键的预处理器 attachment 。

在这里插入图片描述

下载离线安装和HTTP在线安装

Ingest-attachment 插件下载地址:
https://artifacts.elastic.co/downloads/elasticsearch-plugins/ingest-attachment/ingest-attachment-{ElasticsearchVersion}.zip
例如 ES 版本是 7.3.2,则修改下载地址中的变量为 7.3.2 后的下载地址最后的文件名为 ingest-attachment-7.3.2.zip

在安装目录下运行的离线安装命令为

Linux离线

./bin/elasticsearch-plugin install file:///path/to/ingest-attachment-7.3.2.zip

Windows离线

./bin/elasticsearch-plugin install file:///C:/path/to/ingest-attachment-7.3.2.zip

HTTP在线

sudo ./bin/elasticsearch-plugin install http://some.domain/path/to/ingest-attachment-7.3.2.zip

插件安装后如果没有生效,则重启 es 服务。

官网资料:https://www.elastic.co/guide/en/elasticsearch/plugins/current/index.html

定义文本抽取管道

PUT /_ingest/pipeline/attachment
{
    "description": "Extract attachment information",
    "processors": [
        {
            "attachment": {
                "field": "content",
                "ignore_missing": true
            }
        },
        {
            "remove": {
                "field": "content"
            }
        }
    ]
}

在attachment中指定要过滤的字段为content,所以写入Elasticsearch时需要将文档内容放在content字段。

执行命令后响应结果如下:

{
    "acknowledged":true
}

(END)

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐