zoukankan      html  css  js  c++  java
  • solr从pdf、office文档中建立索引

    转载自 :http://www.superwu.cn/2015/05/28/2492/

    tika-data-config.xml

         

            
     

    <dataConfig>   

           <dataSource type="BinFileDataSource" /> 

               <document> 

                <entity    name="files" dataSource="binary"    rootEntity="false"

                      processor="FileListEntityProcessor" 

                baseDir="D:/temp"    fileName=".*.(doc)|(pdf)|(xls)|(ppt)|(docx)"

                   recursive="true"> 

                    <field    column="fileAbsolutePath" name="id" /> 

                    <field    column="fileSize" name="size" /> 

                    <field    column="fileLastModified" name="lastModified" /> 

                    <entity 

                           name="documentImport" 

                           processor="TikaEntityProcessor" 

                           url="${files.fileAbsolutePath}" 

                           format="text">

                        <field    column="file" name="fileName"/>

                        <field    column="Author" name="author" meta="true"/> 

                        <field    column="title" name="title" meta="true"/> 

                        <field    column="text" name="text"/> 

                    </entity> 

                    </entity> 

               </document> 

    </dataConfig>    

        
     

    这里只说上面(7.2)没有说过的属性。

    ·        fileName :(必选)使用正则表达式匹配文件

    ·        baseDir : (必选) 文件目录

    ·        recursive : 是否递归的获取文件,默认false

    ·        rootEntity :在这里必须是false(除非你只想索引文件名)。在默认情况下,document元素下就是根实体了,如果没有根实体的话,直接在实体下面的实体将会被看做跟实体。对于根实体对应的数据库中返回的数据的每一行,solr都将生成一个document

    ·        dataSource :如果你是用solr1.3,那就必须设为"null",因为它没使用任何dataSourde。不需要在solr1.4中指定它,它只是意味着我们不创建一个dataSource实例。在大多数情况下,只有一个DataSource(JdbcDataSource),当使用FileListEntityProcessor 的时候DataSource不是必须的

    ·        processor:只有当datasource不是RDBMS时才是必须的

    ·        onError :默认是"abort","skip"表示跳过当前文档,"continue"表示对错误视而不见

  • 相关阅读:
    ASM ClassReader failed to parse class file- probably due to a new Java class file version that isn't supported yet问题
    Git配置工作
    Git多人协作
    Git分支合并
    网络收藏夹
    莫道桑榆晚,为霞尚满天
    2021幼升小
    2020年07月28日10:36:36
    JAVA中如果用BigDecimal做除法
    mybatis
  • 原文地址:https://www.cnblogs.com/Zhong-Xin/p/5620545.html
Copyright © 2011-2022 走看看