简体   繁体   English

用于删除文档的 Solr 发布文件

[英]Solr post files for deleting documents

I want to delete some documents from solr using bin/post command我想使用bin/post命令从 solr 中删除一些文件

I am trying to delete json documents.我正在尝试删除 json 文档。 here is my file tobedeleted.json with ids这是我的带有 ids 的文件tobedeleted.json

{"delete": ["1219073", "2234630", "120270", "244755", "2275454", "2121923", "2280254", "2261038", "1232067", "1227748"]}

I am using /solr/bin/post -c mycore -d tobedeleted.json我正在使用/solr/bin/post -c mycore -d tobedeleted.json

but it is throwing error as但它抛出错误

    java -classpath /opt/solr/dist/solr-core-6.1.0.jar -Dauto=yes -Dc=projects -Ddata=args org.apache.solr.util.SimplePostTool /home/ansible/aws/data/DL_PT_20171205_20.json
SimplePostTool version 5.0.0
POSTing args to http://localhost:8983/solr/projects/update...
SimplePostTool: WARNING: Solr returned an error #400 (Bad Request) for url: http://localhost:8983/solr/projects/update
SimplePostTool: WARNING: Response: <?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">400</int><int name="QTime">1</int></lst><lst name="error"><lst name="metadata"><str name="error-class">org.apache.solr.common.SolrException</str><str name="root-error-class">com.ctc.wstx.exc.WstxUnexpectedCharException</str></lst><str name="msg">Unexpected character '/' (code 47) in prolog; expected '&lt;'
 at [row,col {unknown-source}]: [1,1]</str><int name="code">400</int></lst>
</response>
SimplePostTool: WARNING: IOException while reading response: java.io.IOException: Server returned HTTP response code: 400 for URL: http://localhost:8983/solr/projects/update
COMMITting Solr index changes to http://localhost:8983/solr/projects/update...
Time spent: 0:00:00.021
You have mail in /var/spool/mail/ansible

Please, can you let me know how can I delete documents using post utility?拜托,你能告诉我如何使用邮政实用程序删除文件吗?

I have done workaround for it using curl.我已经使用 curl 解决了它。 But if anybody have better solution please suggest.但如果有人有更好的解决方案,请提出建议。

You could try by creating a bash script.您可以尝试创建一个 bash 脚本。 Put the document ids inside an array.将文档 ID 放入数组中。 Then loop the document ids using the following bin/post command:然后使用以下 bin/post 命令循环文档 ID:

bin/post -c "collection name" -d '<delete><id>"document id"</id></delete>'

Ex: bin/post -c gettingstarted -d '<delete><id>42</id></delete>'例如: bin/post -c gettingstarted -d '<delete><id>42</id></delete>'

(from https://lucene.apache.org/solr/guide/7_4/post-tool.html ) (来自https://lucene.apache.org/solr/guide/7_4/post-tool.html

One word of advice, as I had issues with the post tool yesterday: restart your Zookeeper and then your Solr ensembles before you proceed using the post tool.一个忠告,因为我昨天在使用 post 工具时遇到了问题:在继续使用 post 工具之前,重新启动 Zookeeper 和 Solr 集成。

All the best!一切顺利!

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

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