简体   繁体   English

没有扩展名的SOLR POST文件

[英]SOLR POST files with no extension

I am using SOLR 5 and I want to scan documents that have no extensions. 我正在使用SOLR 5,并且想扫描没有扩展名的文档。 Unfortunately changing the file to have extensions is not an option in my case. 不幸的是,就我而言,将文件更改为具有扩展名不是一种选择。

the command I am using is simply: 我使用的命令很简单:

$bin/post -c mycore ../foldertobescaned -type application/pdf

the command works fine for documents that do have extension but I am getting: 该命令适用于具有扩展名的文档,但我得到:

Entering auto mode. 进入自动模式。 File endings considered are xml,json,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log 考虑的文件结尾是xml,json,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log

If renaming the files is not an option, you can use the following script as a workaround until Solr improves its post method. 如果不能重命名文件,则可以使用以下脚本作为变通办法,直到Solr改进其post方法。 It is a simple bash for loop that submits each file individually and works regardless of the file extension. 这是一个简单的bash for循环,可单独提交每个文件,并且无论文件扩展名如何都可以工作。 Note that this script will be slower than using post on the whole folder, because each individual file transfer needs to be initialized. 请注意,此脚本要比在整个文件夹上使用post慢,因为每个文件传输都需要初始化。

Save the script below as postFolderToSolr.sh inside your Solr folder (so that Solrs bin/ folder is a subdirectory), make it executable with chmod +x postFolderToSolr.sh and then use it as follows: ./postFolderToSolr.sh mycore /home/user1/foldertobescaned/ application/pdf 下面保存作为脚本postFolderToSolr.sh您Solr的文件夹中(这样Solrs bin/文件夹是一个子目录),使其可执行与chmod +x postFolderToSolr.sh ,然后用它如下: ./postFolderToSolr.sh mycore /home/user1/foldertobescaned/ application/pdf

Using no arguments or the wrong number of arguments prints a short usage message as help. 不使用任何参数或参数数量错误会打印一条简短的用法消息作为帮助。

#!/bin/bash
set -o nounset

if [ "$#" -ne 3 ]
then
echo "Post contents of a folder to Solr."
echo
echo "Usage: postFolderToSolr.sh <colletionName> </path/to/folder> <MIME>"
echo
exit 1
fi

collection=$1
inputPath=${2%/} # remove suffix / if it exists
mime=$3

for element in $inputPath"/"*; do
    bin/post -c $collection -type $mime $element
done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM