本文整理汇总了Python中solr.SolrConnection.delete方法的典型用法代码示例。如果您正苦于以下问题:Python SolrConnection.delete方法的具体用法?Python SolrConnection.delete怎么用?Python SolrConnection.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solr.SolrConnection
的用法示例。
在下文中一共展示了SolrConnection.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _send_update
# 需要导入模块: from solr import SolrConnection [as 别名]
# 或者: from solr.SolrConnection import delete [as 别名]
def _send_update(self, *args, **kwargs):
"""Send an update request to Solr.
Solr commits are made only on deletion.
Takes a single argument: the AMQP message that was received.
"""
try:
log.info("Processing update request")
msg = args[0]
updates = json.loads(msg.body)
solr = SolrConnection(self.solr_uri)
if updates["type"] == "updated":
add = ET.Element("add")
for update in updates["data"]:
doc = ET.SubElement(add, "doc")
for fields in update:
# There should only be one pair
# FIXME: move to a dictionary structure
for k, v in fields.items():
SolrUpdater.xml_field(doc, solr.escapeKey(k), solr.escapeVal(v))
log.debug("Sending update to Solr: " + ET.tostring(add))
solr.doUpdateXML(ET.tostring(add))
elif updates["type"] == "deleted":
for id in updates["data"]:
log.debug("Deleting document with id '%s'" % id)
solr.delete(id)
solr.commit()
elif updates["type"] == "deleted_db":
db_name = updates["data"]
log.info("Deleting indexes for database '%s'" % db_name)
solr.deleteByQuery("_db:%s" % db_name)
solr.commit()
else:
log.warning("Unrecognized update type: '%s'" % updates["type"])
except Exception:
log.exception("Unexpected exception")
示例2: open
# 需要导入模块: from solr import SolrConnection [as 别名]
# 或者: from solr.SolrConnection import delete [as 别名]
with open("sample_redis_manifest.rdf", "r") as f:
graph.parse(f, base="sample_redis_manifest.rdf")
except IOError, e:
pass
# graph.parse('http://10.0.1.154/'+silo_name +"/datasets/" + item_id +"/manifest.rdf")
# graph.parse(data=respdata, format="application/rdf+xml")
# graph.parse(data=respdata, format="n3")
# graph = respdata
solr = SolrConnection(c.get(worker_section, "solrurl"))
solr_doc = gather_document("DataFinder", uuid, item_id, graph)
# solr_doc = {'identifier': ['wed1'], 'aggregatedResource': ['http://datafinder-d2v.bodleian.ox.ac.uk/DataFinder/datasets/wed1/df_manifest_wed1.rdf'], 'mediator': ['admin'], 'text': ['yes', '', 'zool0982', '', '', 'http://vocab.ox.ac.uk/projectfunding#', '', 'seeking_approval', '', ''], 'embargoedUntilDate': ['2083-05-29T07:54:46Z'], 'alternative': ['wed1title'], 'id': ['wed1'], 'subject': [''], 'rights': ['http://ora.ouls.ox.ac.uk/objects/uuid%3A1d00eebb-8fed-46ad-8e38-45dbdb4b224c'], 'publisher': ['Bodleian Libraries, University of Oxford'], 'license': ['CC0 1.0 Universal (CC0 1.0). See http://creativecommons.org/publicdomain/zero/1.0/legalcode'], 'uuid': [u'51b51cd8e78f4da2951e288078cf3821'], 'language': [''], 'title': ['wed1'], 'embargoStatus': ['False'], 'description': ['wed1desc'], 'format': [''], 'modified': ['2013-05-29 07:54:46.606822'], 'filename': ['wed1/df_manifest_wed1.rdf'], 'currentVersion': ['2'], 'created': ['2013-05-29 07:54:46.360052'], 'silo': ['DataFinder'], 'type': ['', 'http://vocab.ox.ac.uk/dataset/schema#DataSet']}
# print "solr_doc = gather_document('DataFinder' ,"+ str(uuid)+" , "+ str(item_id)+" , "+str(graph)+" )"
print solr_doc
solr_doc = {"id": ["mond_ay2"], "silo": ["DataFinder"]}
solr.delete(id="mond_ay2")
print "deleted'"
solr_doc = {
"id": ["mond_ay2"],
"silo": ["DataFindehhhhr"],
"uuid": [u"78755d851f9a453b84a51b1c00c68553"],
"depositor": "zool0982"
# 'identifier': ['fri_day1'],
# 'aggregatedResource': ['http://datafinder-d2v.bodleian.ox.ac.uk/DataFinder/datasets/fri_day1/df_manifest.rdf'],
# 'mediator': ['admin'],
# 'text': ['', 'http://vocab.ox.ac.uk/projectfunding#', '', 'seeking_approval', '', '', 'yes', '', ''],
# 'depositor': ['zool0982'],
# 'embargoedUntilDate': ['2083-06-21T14:08:45Z'],
# 'alternative': ['fri_day1'],
# 'subject': [''],
示例3: solr_index
# 需要导入模块: from solr import SolrConnection [as 别名]
# 或者: from solr.SolrConnection import delete [as 别名]
def solr_index(med):
lists = []
countries = []
sections = []
subsections = []
pharma_form_list = []
pharma_form_type_list = []
category_list = []
observation_list = []
# if medicine status is not active delete from solr index
if not med.active:
try:
solr = SolrConnection(settings.SOLR_URL)
solr.delete(id=str(med.id))
response = solr.commit()
except Exception as ex:
return False
return True
# index medicine on solr index
medicine_translations = MedicineLocal.objects.filter(medicine=med.id)
medicine_list = ['en^%s' % med.name.strip()]
for translation in medicine_translations:
medicine_list.append('%s^%s' % (translation.language, translation.name.strip()))
medicine_list = "|".join(medicine_list) # ex.: en^codeine|pt-br^codeína|es^codeína
# retrieve actives pharmaceutical forms of currente medicine
pharm_forms = med.pharmaceuticalform_set.filter(active=True)
for form in pharm_forms:
# ex. ^enTablet|es^Tableta|pt-br^Comprimido
pharma_form_type_translations = "|".join( form.pharmaceutical_form_type.get_translations() )
pharma_form_type_list.append(pharma_form_type_translations)
# ex. ^enTablet|es^Tableta|pt-br^Comprimido|comp^15 mg/ml
pharma_form_list.append('%s|comp^%s' % (pharma_form_type_translations, form.composition))
# create category_list (section and subsection where current pharmaceutical form is used on lists)
section_pharm_form_list = SectionPharmForm.objects.filter(pharmaceutical_form=form)
for section_pharm_form in section_pharm_form_list:
#add observations of current section_pharm_form
if section_pharm_form.only_for_children:
observation_list.append('only_for_children')
if section_pharm_form.specialist_care_for_children:
observation_list.append('specialist_care_for_children')
if section_pharm_form.restriction_age:
observation_list.append('restriction_age')
if section_pharm_form.best_evidence:
observation_list.append('best_evidence')
if section_pharm_form.observation:
observation_list.append('observation')
section = Section.objects.get(pk=section_pharm_form.section.id)
section_translations = "|".join(section.get_translations())
section_tree = section.get_ancestors()
if section_tree:
for sec in section_tree:
category_translations = "|".join(sec.get_translations())
if category_translations not in category_list:
category_list.append(category_translations)
if section_translations not in category_list:
category_list.append(section_translations)
list_associated = "|".join( section.list.get_translations() )
if section.list.type == 'c':
if list_associated not in countries:
countries.append(list_associated)
else:
if list_associated not in lists:
lists.append(list_associated)
#check if current medicine have Evidence summaries
has_evidence = None
evidence_total = MedicineEvidenceSummary.objects.filter(medicine=med.id).count()
if evidence_total > 0:
has_evidence = "true"
# try to create a connection to a solr server and send medicine
try:
solr = SolrConnection(settings.SOLR_URL)
solr.add(
id = str(med.id),
type = "medicine",
name = medicine_list,
pharmaceutical_form = pharma_form_list,
pharmaceutical_form_type = pharma_form_type_list,
list=lists,
country=countries,
category=category_list,
observation=observation_list,
has_evidence=has_evidence,
)
response = solr.commit()
#.........这里部分代码省略.........
示例4: gather_document
# 需要导入模块: from solr import SolrConnection [as 别名]
# 或者: from solr.SolrConnection import delete [as 别名]
if msg['type'] == "c" or msg['type'] == "u":
# Creation
itemid = msg.get('id')
print "Got creation message on id:%s in silo:%s" % (itemid, silo_name)
if itemid and s.exists(itemid):
# Embargo flag?
item = s.get_item(itemid)
if item.metadata.get('embargoed', True) not in ['true','True', True]:
solr_doc = gather_document(silo_name, item)
solr.add(_commit=True, **solr_doc)
rq.task_complete()
elif msg['type'] == "d":
# Deletion
itemid = msg.get('id')
if itemid and s.exists(itemid):
solr.delete(itemid)
solr.commit()
rq.task_complete()
elif msg['type'] == "embargo":
itemid = msg.get('id')
if itemid and s.exists(itemid):
if msg['embargoed'] in ['false', 'False', 0, False]:
# Embargo removed: update solr
item = s.get_item(itemid)
solr_doc = gather_document(silo_name, item)
solr.add(_commit=True, **solr_doc)
else:
solr.delete(itemid)
solr.commit()
rq.task_complete()
except NoSuchSilo: