python - Solr:删除id中带有尖括号的文档
问题描述
我正在尝试从 Solr 索引中删除文档。我正在使用 pysolr 并尝试通过 id 和查询删除它们。在这两种情况下,操作都会失败,并带有如下 ID:cr-10.1002/(sici)1520-6688(199621)15:2<476::aid-pam7>3.3.co;2-2
出现以下错误:
pysolr.SolrError: Solr responded with an error (HTTP 400): [Reason: Unexpected character '4' (code 52) in content after '<' (malformed start element?).
at [row,col {unknown-source}]: [1,53]]
https://lucene.apache.org/core/7_2_1/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Escaping_Special_Characters根本没有提到转义尖括号。我试过了,但没有运气。
知道我可以做些什么来删除这些文件吗?
编辑:更新了 ID 以匹配错误
解决方案
我最终使用了这样的 JSON API:
import requests
url = 'http://localhost:8983/solr/collection/update' # update endpoint of the collection
ids_to_delete = ['a', 'b<c', 'd:e']
requests.post(url, json={ 'delete': ids_to_delete })
推荐阅读
- php - 在laravel中使用表中的对象数组
- flutter - 如何创建在使用 AnimationController 创建的倒数计时器期间发出的警报?
- java - Java中的基本继承帮助
- c# - 在配置文件中填写部分
- ios - 无法在 iOS 12 的文档选择器中选择文件夹
- python - 重新训练模型开始时的损失比上次会话结束时更高
- php - 我需要在单行中与用户一起获取表格阶段的计数应该是动态的
- java - 按钮在模拟器上有效,但在真手机上无效
- scikit-learn - 带有 RF、PCA 和 CV 生成错误的管道
- google-apps-script - 如何在 google sheet 自定义函数中使用 FormApp.create?