Skip to content

Commit

Permalink
update deprecated method calls and add remove from search index method
Browse files Browse the repository at this point in the history
  • Loading branch information
joshz committed Nov 14, 2012
1 parent 0e08c22 commit e3e3fbd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions uplusmessaging/util/searching.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,16 @@ def delete_all_in_index(index_name):
while True:
# Get a list of documents populating only the doc_id field and extract the ids.
document_ids = [document.doc_id
for document in doc_index.list_documents(ids_only=True)]
for document in doc_index.get_range(ids_only=True)]
if not document_ids:
break
# Remove the documents for the given ids from the Index.
doc_index.remove(document_ids)
doc_index.delete(document_ids)

def remove_from_index(doc_id, index_name='users'):
doc_index = search.Index(name=index_name)
try:
doc_index.delete(doc_id)
except search.DeleteError:
return False
return True

0 comments on commit e3e3fbd

Please sign in to comment.