Example #1
0
 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()
Example #2
0
    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()
Example #3
0
 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()
Example #4
0
 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)
Example #5
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()
Example #6
0
 def remove(self, documentIdentifier):
     self.reader.deleteDocuments(
         PyLucene.Term('storeID', documentIdentifier))