def clear(self, models): """Clear the entire index of a certain model.""" self._open_index() for model in models: term = PyLucene.Term(MODEL_FIELD, str(model._meta)) self._index.deleteDocuments(term) self._close_index()
def delete_existing_feed_docs(self, feed): """ deletes existing documents relating to the given feed """ reader = lucene.IndexReader.open(self.feed_modifier.store) numDeleted = reader.deleteDocuments(lucene.Term('url', feed.xml_url)) logging.info('deleted %d existing index documents' % numDeleted) reader.close() reader = lucene.IndexReader.open(self.entry_modifier.store) for entry in feed.get_entries(): try: id = '%s:%s' % (feed.xml_url, entry.get('id', None)) numDeleted = reader.deleteDocuments(lucene.Term('id', id)) if numDeleted: logging.info('deleted %d feed entry docyments' % numDeleted) except: {} reader.close()
def unindex_record(self, record): """ Unindex documents matching this entry's uid. *Should* only be one, but could be many, if somehow the same entry got indexed multiple times. """ reader = self.context.get_search_index_reader() term = PyLucene.Term('uid', str(record.uid)) reader.deleteDocuments(term) reader.close()
def delete_node(self, nid): try: index_present = len(os.listdir('index')) > 0 if index_present: reader = PyLucene.IndexReader.open("index") term = PyLucene.Term(COLUMN_NID, nid) if reader.termDocs(term) != None: reader.deleteDocuments(term) reader.close() except: IBASGlobal.print_message( "Error while deleting document from Lucene with nid " + str(nid), 0)
def remove(self, obj): """Remove an object from the index.""" self._open_index() term = PyLucene.Term(IDENTIFIER_FIELD, self.get_identifier(obj)) self._index.deleteDocuments(term) self._close_index()
def remove(self, documentIdentifier): self.reader.deleteDocuments( PyLucene.Term('storeID', documentIdentifier))