参照:solr6.6 导入 pdf文件

  重点就是三个配置文件

  1、建立的data-config.xml

    内容如下:

<dataConfig>
<dataSource name="fileDataSource" type="FileDataSource" /> <!--<document>
<entity name="tika-test" processor="TikaEntityProcessor"
url="C:/docs/solr-word.pdf" format="text">
<field column="Author" name="author" meta="true"/>
<field column="title" name="title" meta="true"/>
<field column="text" name="text"/>
</entity>
</document>--> <dataSource name="urlDataSource" type="BinURLDataSource" />
<!--baseDir="D:/work/Solr/solr-6.6.0/ImportDoc" fileName=".*\.(doc)|(pdf)|(docx)|(txt)"-->
<document>
<entity name="files" dataSource="null" rootEntity="false"
processor="FileListEntityProcessor"
baseDir="D:/work/Solr/solr-6.6.0/ImportDoc" fileName=".*\.(json)|(txt)|(csv)|(xml)"
onError="skip"
recursive="true">
<field column="file" name="id"/> <field column="fileAbsolutePath" name="filePath" />
<field column="fileSize" name="size" />
<field column="fileLastModified" name="lastModified" /> <entity processor="PlainTextEntityProcessor" name="txtfile" url="${files.fileAbsolutePath}" dataSource="fileDataSource">
<field column="plainText" name="text"/>
</entity>
</entity>
</document>
</dataConfig>

 2、修改managed-schema文件

    增加如下内容:

 <!-- mmseg4j fieldType-->
<fieldType name="text_mmseg4j_complex" class="solr.TextField" positionIncrementGap="100" >
<analyzer>
<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="complex" />
</analyzer>
</fieldType>
<fieldType name="text_mmseg4j_maxword" class="solr.TextField" positionIncrementGap="100" >
<analyzer>
<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word" />
</analyzer>
</fieldType>
<fieldType name="text_mmseg4j_simple" class="solr.TextField" positionIncrementGap="100" >
<analyzer>
<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple" />
</analyzer>
</fieldType> <field name="text" type="text_mmseg4j_complex" indexed="true" stored="true" omitNorms="true" multiValued="false"/>
<field name="fileName" type="string" indexed="true" stored="true" />
<field name="filePath" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="size" type="long" indexed="true" stored="true" />
<field name="lastModified" type="date" indexed="true" stored="true" />

  

  3、修改solrconfig.xml文件

 <lib dir="./lib" regex=".*\.jar"/>

  4、导入文件

  

    注意,txt文件编码请保证是UTF-8编码,默认txt文件的编码是GBK

  5、查询

    导入成功后,查询

    

    从上面可以看到,pdf和word文件是乱码,必须用其它Processor进行处理

solr6.6 导入 文本(txt/json/xml/csv)文件的更多相关文章

  1. 导出Excel/Pdf/txt/json/XML/PNG/CSV/SQL/MS-Word/ Ms-Powerpoint/等通过tableExport.js插件来实现

    首先去我的云盘下载需要的js: 链接:https://pan.baidu.com/s/13vC-u92ulpx3RbljsuadWw 提取码:mo8m 页面代码: <!DOCTYPE html& ...

  2. Java 对不同类型的数据文件的读写操作整合器[JSON,XML,CSV]-[经过设计模式改造](2020年寒假小目标03)

    日期:2020.01.16 博客期:125 星期四 我想说想要构造这样一个通用文件读写器确实不容易,嗯~以后会添加更多的文件类型,先来熟悉一下文件内容样式: <?xml version=&quo ...

  3. json和csv文件存储

    一. json 1:基本概念 1.1 Json和Javascript JSON, 全称JavaScript Object Notation,它通过对象和数组的组合来表示数据.在JavaScript中一 ...

  4. MySQL导入含有中文字段(内容)CSV文件乱码解决方法

    特别的注意:一般的CSV文件并不是UTF-8编码,而是10008(MAC-Simplified Chinese GB 2312),所以再通过Navicat导入数据的时候需要指定的编码格式是10008( ...

  5. Solr json,xml等文件数据导入(添加索引)linux下操作

    使用solr-5.3.1\example\exampledocs下的post.jar来完成数据导入 1.将想要导入的文件放在solr-5.3.1\example\exampledocs中,如aaa.x ...

  6. CSV文件导入导mysql数据库

    1.导入 基本语法: load data [low_priority] [local] infile 'file_name txt' [replace | ignore] into table tbl ...

  7. Oracle数据库导入csv文件(sqlldr命令行)

    1.说明 Oracle数据库导入csv文件, 当csv文件较小时, 可以使用数据库管理工具, 比如DBevaer导入到数据库, 当csv文件很大时, 可以使用Oracle提供的sqlldr命令行工具, ...

  8. mysql SQLyog导入导出csv文件

    1.选择数据库表 --> 右击属性 --> 备份/导出 --> 导出表数据作为 --> 选择cvs --> 选择下面的“更改” --> 字段 --> 变量长度 ...

  9. MongoDB:数据导入CSV文件之错误记录

    测试主机1:Windows 10,MongoDB 3.6.3,WPS 10.1,Notepad++ 7.5.3, 测试主机2:Ubuntu 16.04,MongoDB 4, 今天测试了将数据从文件—— ...

随机推荐

  1. 1、使用Xcode修改iOS项目工程名和路径名

    http://blog.sina.com.cn/s/blog_a42013280101blxo.html 对,好:错,改正. ------ 前言 系统 10.7 狮子 开发平台 xcode 4.5.2 ...

  2. linux设备驱动中的并发控制【转】

    转自:http://www.cnblogs.com/plinx/archive/2013/01/28/2873121.html 在linux内核中,主要的静态发生于以下几种情况: 1.对称多处理器(S ...

  3. Oracle 10g 安装环境配置脚本

    #!/bin/bash #Test in RHEL 5.5 for 10g c=`cat /etc/shadow | grep oracle | wc -l`if [ $c != 0 ]then  w ...

  4. PHPExcel 长数字串显示为科学计数 与 其他错误

    一.解决 PHPExcel 长数字串显示为科学计数 在excel中如果在一个默认的格中输入或复制超长数字字符串,它会显示为科学计算法,例如身份证号码,解决方法是把表格设置文本格式或在输入前加一个单引号 ...

  5. 解决xshell 、SecureCRT中文乱码

    一.解决xshell 中文乱码 在xshell命令行里面 输入: locale输出: LANG=zh_CN.UTF-8LC_CTYPE="zh_CN.UTF-8"LC_NUMERI ...

  6. MYSQL通过索引优化数据库的查询

    #转载请联系 索引是什么? 索引是一种特殊的文件(InnoDB数据表上的索引是表空间的一个组成部分),它们包含着对数据表里所有记录的位置信息. 更通俗的说,数据库索引好比是一本书前面的目录,能加快数据 ...

  7. hdu 1534(差分约束)

    Schedule Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. 将双击“root的主文件”弹出的窗口设置为文件浏览器

    1.双击桌面"root的文件夹"图标, 在过去Centos版本之前,每次双击“root主文件夹”都会弹出文件管理窗口: 解决办法:         关闭所有窗口后,重新双击图标: ...

  9. requests库使用socks5代理

    备查: #!usr/bin/env python # coding=utf-8 import requests proxies = {'https': 'https://127.0.0.1:1080' ...

  10. 20、Flask实战第20天:Flask上下文

    Local线程隔离对象 我们知道通过request可以获取表单中的数据.如果是多个用户同时在用网站,而全局request就只有一个,那么Flask是如何分辨哪用户对应哪个请求呢? 这种情况下,就会用到 ...