def remove(self, key=None, value=None, entity=None): """ Remove any entries from the index which match the parameters supplied. The allowed parameter combinations are: `key`, `value`, `entity` remove a specific entity indexed under a given key-value pair `key`, `value` remove all entities indexed under a given key-value pair `key`, `entity` remove a specific entity indexed against a given key but with any value `entity` remove all occurrences of a specific entity regardless of key and value """ if key and value and entity: t = ResourceTemplate(self.resource.uri.string + "/{key}/{value}/{entity}") t.expand(key=key, value=value, entity=entity._id).delete() elif key and value: uris = [ URI(entity.resource.metadata["indexed"]) for entity in self.get(key, value) ] batch = LegacyWriteBatch(self.graph) for uri in uris: batch.append_delete(uri) batch.run() elif key and entity: t = ResourceTemplate(self.resource.uri.string + "/{key}/{entity}") t.expand(key=key, entity=entity._id).delete() elif entity: t = ResourceTemplate(self.resource.uri.string + "/{entity}") t.expand(entity=entity._id).delete() else: raise TypeError("Illegal parameter combination for index removal")