Solr: Deleting Documents With Angle Brackets In Id
I'm trying to delete documents from a Solr index. I'm using pysolr and trying to delete them by id and by query. In both cases the operation fails with ids like this one: cr-10.1002/(sici)1520-6688(199621)15:2<476::aid-pam7>3.3.co;2-2
with following error:
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 has no mention of escaping angle brackets at all. I tried it though, with no luck.
Any idea what I can do to delete these documents?
EDIT: updated the ID to match the error
Answer
I ended up using the JSON API like this:
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 })
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module