Indexing 在solr中为文件夹内的所有文件编制索引
我在solr中索引文件夹时遇到问题 示例-data-config.xml:Indexing 在solr中为文件夹内的所有文件编制索引,indexing,solr,lucene,directory,Indexing,Solr,Lucene,Directory,我在solr中索引文件夹时遇到问题 示例-data-config.xml: <dataConfig> <dataSource type="BinFileDataSource" /> <document> <entity name="files" dataSource="null" rootEntity="false" processor="FileListEntityProc
<dataConfig>
<dataSource type="BinFileDataSource" />
<document>
<entity name="files"
dataSource="null"
rootEntity="false"
processor="FileListEntityProcessor"
baseDir="C:\Temp\" fileName=".*"
recursive="true"
onError="skip">
<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="text" name="text"/>
</entity>
</entity>
</document>
然后创建schema.xml:
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="fileName" type="string" indexed="true" stored="true" />
<field name="author" type="string" indexed="true" stored="true" />
<field name="title" type="string" indexed="true" stored="true" />
<field name="size" type="plong" indexed="true" stored="true" />
<field name="lastModified" type="pdate" indexed="true" stored="true" />
<field name="text" type="text_general" indexed="true" stored="true" multiValued="true"/>
最后,我修改了文件solrConfig.xml,添加了requesthandler、dataImportHandler和dataImportHandler额外的JAR:
<requestHandler name="/dataimport" class="solr.DataImportHandler">
<lst name="defaults">
<str name="config">example-data-config.xml</str>
</lst>
</requestHandler>
示例-data-config.xml
我运行它,结果是:
在该文件夹中有大约20.000个不同格式的文件(.py、.java、.wsdl等)
如有任何建议,将不胜感激。谢谢:)查看您的Solr日志。根本原因的答案肯定会在那里。我也曾经遇到过同样的情况,通过solr日志发现我的
DataImportHandler
抛出异常,因为文件夹中存在加密文档。您的原因可能不同,但首先分析您的solr日志,在数据导入
部分再次执行您的实体
,然后通过进入管理页面的日志记录
部分检查即时日志是否存在错误。如果您收到的错误与我之前提到的不同,请将它们张贴在此处,以便理解和解密。检查您的Solr日志。根本原因的答案肯定会在那里。我也曾经遇到过同样的情况,通过solr日志发现我的DataImportHandler
抛出异常,因为文件夹中存在加密文档。您的原因可能不同,但首先分析您的solr日志,在数据导入
部分再次执行您的实体
,然后通过进入管理页面的日志记录
部分检查即时日志是否存在错误。如果您遇到的错误不是我所提到的,请将它们发布到此处,以便理解和破译。似乎recursive=“true”在某种程度上不起作用,我尝试使用一个子文件夹,子文件夹的信息已正确索引。但我现在真的不知道的根本原因似乎是recursive=“true”在某种程度上不起作用,我尝试了一个子文件夹,子文件夹的信息被正确地索引了。但根本原因我现在真的不知道,谢谢你的快速回复:)。我查看了日志,似乎Solr在尝试索引.png图像时出现了问题,所以我现在正在做的是列出所有没有有用信息的文件(如png、jpg、swf等),并且不对它们进行索引。在这里发布您在日志中获得的内容。如果我的回答对你有帮助的话,我希望你能接受:)谢谢你的快速回复:)。我查看了日志,似乎Solr在尝试索引.png图像时出现了问题,所以我现在正在做的是列出所有没有有用信息的文件(如png、jpg、swf等),并且不对它们进行索引。在这里发布您在日志中获得的内容。如果我的回答对你有帮助,你愿意接受吗:)