How to make atomic updates to solr using pysolr?

醉酒当歌 提交于 2019-12-11 02:20:17

问题


I can't find a decent documentation on how to make updates to solr using pysolr.


回答1:


You cannot currently make atomic updates to Solr using PySolr. There is a pull for it:

https://github.com/toastdriven/pysolr/pull/99

But it's not yet been merged. Last comment was less than a month ago, if you are interested I'd comment on it - or try to merge the code yourself if you feel up to it.




回答2:


As of November 2014 atomic updates are supported with pysolr. Here's a simple example:

url_solr = '''http://my.solr.com:8983/solr/mycore'''
solr = pysolr.Solr(url_solr)

doc = {'id':'rabid bananas', 'comment':'now half off!'}
solr.add([doc], fieldUpdates={'comment':'set'})
# the id 'rabid bananas' now has an updated comment



回答3:


Using the same unique Solr ID and writing as usual (with solr.add) will overwrite/update the document. So, you can just write the new document setting the unique ID to match the old one that you want to update or you can pull the old document, do the change and gain make a new write using that updated document; since its the same ID you will still be overwriting/updating.



来源:https://stackoverflow.com/questions/24415659/how-to-make-atomic-updates-to-solr-using-pysolr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!