# needed so we can import superfastmatch.Client
from __future__ import absolute_import
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'], defer=True)

@@ -619,16 +619,28 @@
 d, text,
+ defer=True,
  **doc%5B'
@@ -649,22 +649,10 @@
 tadata'%5D
-, defer=True
 )%0A

fix superfastmatch defer syntax