ElasticSearch插件--tika安装

该插件为ElasticSearch添加了附件类型,利用Tika解析多种格式的文件,如Office文档、EPUB等,并能自动抽取元数据如作者、日期等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Mapper Attachments Type for ElasticSearch

The mapper attachments plugin adds the attachment type to ElasticSearch using Tika.

In order to install the plugin, simply run:bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/1.8.0.

------------------------------------------------------
| Attachment Mapper Plugin | ElasticSearch    | Tika |
------------------------------------------------------
| 1.9.0-SNAPSHOT (master)  | 0.90.3 -> master | 1.2  |
------------------------------------------------------
| 1.8.0                    | 0.90.3 -> master | 1.2  |
------------------------------------------------------
| 1.7.0                    | 0.90 -> 0.90.2   | 1.2  |
------------------------------------------------------
| 1.6.0                    | 0.19 -> 0.20     | 1.2  |
------------------------------------------------------
| 1.5.0                    | 0.19 -> 0.20     | 1.2  |
------------------------------------------------------
| 1.4.0                    | 0.19 -> 0.20     | 1.1  |
------------------------------------------------------
| 1.3.0                    | 0.19 -> 0.20     | 1.0  |
------------------------------------------------------
| 1.2.0                    | 0.19 -> 0.20     | 1.0  |
------------------------------------------------------
| 1.1.0                    | 0.19 -> 0.20     |      |
------------------------------------------------------
| 1.0.0                    | 0.18             |      |
------------------------------------------------------

The attachment type allows to index different "attachment" type field (encoded as base64), for example, microsoft office formats, open document formats, ePub, HTML, and so on (full list can be found here).

The attachment type is provided as a plugin extension. The plugin is a simple zip file that can be downloaded and placed under $ES_HOME/plugins location. It will be automatically detected and the attachment type will be added.

Using the attachment type is simple, in your mapping JSON, simply set a certain JSON element as attachment, for example:

{
    "person" : {
        "properties" : {
            "my_attachment" : { "type" : "attachment" }
        }
    }
}

In this case, the JSON to index can be:

{
    "my_attachment" : "... base64 encoded attachment ..."
}

Or it is possible to use more elaborated JSON if content type or resource name need to be set explicitly:

{
    "my_attachment" : {
        "_content_type" : "application/pdf",
        "_name" : "resource/name/of/my.pdf",
        "content" : "... base64 encoded attachment ..."
    }
}

The attachment type not only indexes the content of the doc, but also automatically adds meta data on the attachment as well (when available). The metadata supported are: datetitleauthor, and keywords. They can be queried using the "dot notation", for example: my_attachment.author.

Both the meta data and the actual content are simple core type mappers (string, date, ...), thus, they can be controlled in the mappings. For example:

{
    "person" : {
        "properties" : {
            "file" : {
                "type" : "attachment",
                "fields" : {
                    "file" : {"index" : "no"},
                    "date" : {"store" : "yes"},
                    "author" : {"analyzer" : "myAnalyzer"}
                }
            }
        }
    }
}

In the above example, the actual content indexed is mapped under fields name file, and we decide not to index it, so it will only be available in the _all field. The other fields map to their respective metadata names, but there is no need to specify the type (like string or date) since it is already known.

本文出自:https://github.com/elasticsearch/elasticsearch-mapper-attachments

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值