简体   繁体   English

Solr:可以使用post.jar在文件夹和子文件夹中递归发布文件

[英]Solr : Can post.jar be used to post files recursively within folder and subfolder

If I would like to post all the xml files in a folder then I use post.jar. 如果我想将所有xml文件发布到一个文件夹中,则可以使用post.jar。

java -jar post.jar *.xml java -jar post.jar * .xml

In case if I would like to post the files recursively ( ie post xml files under subfolder level also is there anyway to achieve this.) 如果我想递归地发布文件(即也可以在子文件夹级别下发布xml文件)。

If you're on a unix-like (OSX or Linux), you can do something like this: 如果您使用的是类似Unix的操作系统(OSX或Linux),则可以执行以下操作:

find . -name \*xml | xargs java -jar post.jar 

That'll find all .xml files in or under the current directory ('.') and pass them as parameters to the java -jar post.jar command. 这将在当前目录('。')或以下找到所有.xml文件,并将它们作为参数传递给java -jar post.jar命令。

find is incredibly opaque, but very useful for stuff like this. find非常不透明,但是对于这样的东西非常有用。

Yes, you can! 是的你可以!

You just need to ad the -Drecursive flag. 您只需要广告-Drecursive标志。

java -Drecursive -jar post.jar *

For further options for the flags and usage just use: 有关标志和用法的更多选项,请使用:

java -jar post.jar -h

Please think twice before using stuff under the /example directory of Solr. 在使用Solr的/ example目录下的内容之前,请三思。 I use Solr from Tomcat (instead of the Jetty embedded in the start.jar ) and I use URLLIB2 in Python for POSTing data to Solr. 我使用的solr从Tomcat(而不是嵌入在start.jar的码头),我使用的urllib2的Python为发布数据到Solr。 (Jetty is a production-level software, so dont worry too much about that). (Jetty是一种生产级软件,因此不必为此担心太多)。

So, for uploading files, consider writing it in your favorite programming language . 因此,要上传文件,请考虑使用您喜欢的编程语言编写文件。 You can implement folder recursion yourself. 您可以自己实现文件夹递归。 For POSTing files, you need libCURL , which can send HTTP GET, form POSTs, multipart POSTs etc. AC program using libCURL needs no more than 8 lines to POST a file. 对于POST文件,您需要libCURL ,它可以发送HTTP GET,表单POST,多部分POST等。使用libCURL的AC程序只需不超过8行即可发布文件。 CURL bindings exist for all major languages, so you can recycle libCURL stuff written in C to PHP, for example. 所有主要语言都有CURL绑定,因此,例如,您可以将用C编写的libCURL回收到PHP。

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

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