Elasticsearch 6.4 ingest-attachment对文件IK分词器全文检索
这里写自定义目录标题
- 1.简介
- 2.实现步骤
1.简介
ElasticSearch只能处理文本,不能直接处理文档。要实现 ElasticSearch 的附件导入需要以下两个步骤:
一、对多种主流格式的文档进行文本抽取。
二、将抽取出来的文本内容导入 ElasticSearch。
由于 ElasticSearch 是基于 JSON 格式的文档数据库,所以附件文档在插入 ElasticSearch 之前必须进行 Base64 编码。
2.实现步骤
建立自己的文本抽取管道pipeline
1、单文件上传
PUT _ingest/pipeline/simple_attachment
{
“description” : “lhy-单文件管道流”,
“processors”:[
{
“attachment”:{
“field”:“data”,
“indexed_chars” : -1,
“properties”:[“content”, “title”,“content_type”],
“ignore_missing”:true
}
}]
}
2.创建多文件流
PUT _ingest/pipeline/multiple_attachment
{
“description”: “lhy-多文件管道流”
, “processors”: [
{
“foreach”: {
“field”: “attachments”,
“processor”: {
“attachment”: {
“target_field”: “_ingest._value.attachment”,
“field”: “_ingest._value.data”,
“properties”:[“content”, “title”,“content_type”]
}
}
}
}
]
}
3.字段含义:
field : 指定某个字段作为附件内容字段(需要用base64进行加密)
target_field:指定某个字段作为附件信息字段(作者、时间、类型)
indexed_chars : 指定解析文件管道流的最大大小,默认是100000。如果不想限制设置为-1(注意设置为-1的时候如果上传文件过大会而内存不够会导致文件上传不完全)
indexed_chars_field:指定某个字段能覆盖index_chars字段属性,这样子可以通过文件的大小去指定indexed_chars值。
properties: 选择需要存储附件的属性值可以为:content,title,name,author,keyword,date,content_type,content_length,language
ignore_missing: 默认为false,如果设置为true表示,如果上面指定的field字段不存在这不对附件进行解析,文档还能继续保留
导入文档
public void testFileQuery() {
Settings settings = Settings.builder()
.put(“cluster.name”, “my-esLearn”) //连接的集群名
.put(“client.transport.ignore_cluster_name”, true) //如果集群名不对,也能连接
.build();
//创建client
TransportClient transportClient = new PreBuiltTransportClient(settings)
.addTransportAddress(new TransportAddress(InetAddress.getByName("192.168.1.45"), 9300));
String path = "D:\\testFile\\test.doc"
String contentStr = encryptToBase64(path);
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject()
.field("id", "java001")
.field("title", "这是我第一个javaAPI")
.field("data", contentStr)
.endObject();
transportClient.prepareIndex("index","doc","java001").setPipeline("simple_attachment")
.setSource(xContentBuilder).get();
}
public String encryptToBase64(String filePath) {
if (filePath == null) {
return null;
}
try {
byte[] b = Files.readAllBytes(Paths.get(filePath));
return Base64.getEncoder().encodeToString(b);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
查询文档
GET /index/doc/_search
[参考] (https://blog.csdn.net/LazyBoy_Z_z/article/details/82865115)
[参考] (https://blog.csdn.net/LazyBoy_Z_z/article/details/82864264)
Elasticsearch 6.4 ingest-attachment对文件IK分词器全文检索相关推荐
- Elasticsearch 6.4 ingest-attachment对office文件IK分词器全文检索(1) HttpAPI使用
这款插件主要是处理ES中文档解析,如果博友们对ES感兴趣欢迎相互交流:(该文默认你已经具备Es的IK分词器能力) 安装: elasticsearch-plugin install ingest-att ...
- Elasticsearch+elasticsearch-head的安装+Kibana环境搭建+ik分词器安装
一.安装JDK1.8 二.安装ES 三个节点:master.slave01.slave02 1.这里下载的是elasticsearch-6.3.1.rpm版本包 https://www.elastic ...
- 全文检索引擎ElasticSearch:文档管理、集成IK分词器
ElasticSearch 文档管理 添加文档 修改文档 删除文档 文档的查询 IK分词器安装 使用IK分词器 文档管理 添加文档 定位到资源 url http://localhost:9200/{i ...
- Elasticsearch 7.8.1 创建索引,IK分词器的使用
前置知识来自:图解Elasticsearch中的_source._all.store和index属性_1.02^365=1377.41 (Lucene.ES.ELK开发交流群: 370734940, ...
- Elasticsearch实现不同索引使用不同的ik分词器词典
需求说明 原本在IK中,所有索引共用一个词典,热更新词库也是对所有的索引有效. 本文实现,不同的索引,可以配置不同的词典数据 词典数据来自于接口,可以是文件,可以是关系型数据库mysql等 提供数据词 ...
- 04.ElasticSearch之IK分词器的安装与使用
ElasticSearch之IK分词器的安装与使用 前言 安装 离线安装 在线安装 ik分词器测试 扩展(停用)词(典) 测试数据 概念 配置词典 1.修改配置文件 2.新建词典 3.自定义内容 4. ...
- 服务器安装配置elasticsearch,kibana,IK分词器和拼音分词器,集群搭建教程
docker安装配置elasticsearch,kibana和IK分词器 elasticsearch文章系列 前置安装docker 创建docker网络 安装Elasticsearch 运行elast ...
- ElasticSerach6.0.1测试拼音分词器,IK分词器,并且次测试语法
第一步:安装ElasticSearch 6.0.1 下载ElasticSerach,下载IK分词器 由于IK和ElasticSerach已经是编译好的,不需要编译,直接在安装解压修改配置文件即可 详情 ...
- ik分词器安装_Elasticsearch-analysis-ik-7.4.0_Linux_安装
ik分词器安装_Elasticsearch-analysis-ik-7.4.0 文章目录 ik分词器安装_Elasticsearch-analysis-ik-7.4.0 IK分词器安装 1.环境准备 ...
最新文章
- 输出程序运行的时间(精确到微秒)
- Ubuntu terminal路径太深,名字太长
- Python爬虫之旅_高性能异步爬虫
- Request登录案例
- 火狐 url 乱码_在Firefox中查看URL作为工具提示
- 表单提交报错405的解决方式
- 自定义字符串函数:strlen,strcat,strcpy,strcmp
- uni app map 地图 漂浮问题及方案
- 第四次作业----刘滔
- java智能提示_【Java】智能提示的设置
- linux系统管理命令使用,Linux系统管理命令使用说明
- Allegro 使用技巧
- HTML5大数据可视化效果(二)可交互地铁线路图
- Android Patcher应用增量更新(App补丁式更新,无需下载整个apk)
- IAR,STVD和STVP的使用
- 对接京东联盟,签名无效
- Zigbee之旅:第一个CC2430程序LED-IAR相关设置
- 代码动态改变view的大小
- html语言乘法口诀表,0044 使用JavaScript在网页上生成九九乘法口诀表
- 第10章 项目干系人管理
热门文章
- Zero-shot Cross-lingual Transfer of Prompt-based Tuning with a Unified Multilingual Prompt
- Amazon丨『云+端』的全球领先者,为何不提是人工智能公司?
- “以电折水、水电共计”智能仪表助力农业灌溉走上新模式
- PADS的layout单个元器件删除时提示“复用元素无法修改,首先打散复用模块”
- 关于西数黑盘那些事 原来这样滴 小伙伴们都惊呆了
- SQL -- 游标(详细)
- 初,中高级宏观经济学区别和联系
- UPC豁免流程精讲!你与大卖的距离,就在这里!
- 数仓学习笔记(5)——数仓搭建(DWD层)
- 【Thymeleaf】Thymeleaf中的判断语句