diff --git a/changelog.rst b/changelog.rst index 9d1ff17..c641bd9 100644 --- a/changelog.rst +++ b/changelog.rst @@ -3,9 +3,10 @@ oyster changelog 0.3.3 ----- +**2012-04-16** * S3 storage backend bugfix * improvements to signal script - * oyster.ext additions + * oyster.ext cloudsearch and superfastmatch 0.3.2 ----- diff --git a/oyster/ext/superfastmatch.py b/oyster/ext/superfastmatch.py new file mode 100644 index 0000000..f72a81c --- /dev/null +++ b/oyster/ext/superfastmatch.py @@ -0,0 +1,21 @@ +from celery.task.base import Task + +from ..core import kernel +from ..conf import settings + +from superfastmatch import Client + +sfm = Client(settings.SUPERFASTMATCH_URL) + + +class SuperFastMatchPush(Task): + """ task that pushes documents to SFM """ + + # results go straight to database + ignore_result = True + + def run(self, doc_id): + doc = kernel.db.tracked.find_one({'_id': doc_id}) + text = kernel.extract_text(doc) + doctype, docid = settings.SUPERFASTMATCH_ID_FUNC(doc_id) + sfm.add(doctype, docid, text, **doc['metadata'])