elasticsearch log fix
This commit is contained in:
parent
ebba8174ee
commit
dd5e94cf86
@ -7,11 +7,11 @@ from ..conf import settings
|
|||||||
from pyes import ES
|
from pyes import ES
|
||||||
|
|
||||||
es = ES(settings.ELASTICSEARCH_HOST)
|
es = ES(settings.ELASTICSEARCH_HOST)
|
||||||
|
log = logging.getLogger('oyster.ext.elasticsearch')
|
||||||
|
|
||||||
class ElasticSearchPush(Task):
|
class ElasticSearchPush(Task):
|
||||||
# results go straight to elasticsearch
|
# results go straight to elasticsearch
|
||||||
ignore_result = True
|
ignore_result = True
|
||||||
log = logging.getLogger('oyster.ext.elasticsearch')
|
|
||||||
|
|
||||||
def run(self, doc_id):
|
def run(self, doc_id):
|
||||||
doc = kernel.db.tracked.find_one({'_id': doc_id})
|
doc = kernel.db.tracked.find_one({'_id': doc_id})
|
||||||
@ -19,19 +19,18 @@ class ElasticSearchPush(Task):
|
|||||||
try:
|
try:
|
||||||
text = kernel.extract_text(doc)
|
text = kernel.extract_text(doc)
|
||||||
if not text:
|
if not text:
|
||||||
self.log.info('no text for %s', doc_id,
|
log.info('no text for %s', doc_id,
|
||||||
extra={'doc_class':doc['doc_class']})
|
extra={'doc_class':doc['doc_class']})
|
||||||
return
|
return
|
||||||
|
|
||||||
self.log.info('tracked %s', doc_id,
|
log.info('tracked %s', doc_id,
|
||||||
extra={'doc_class':doc['doc_class']})
|
extra={'doc_class':doc['doc_class']})
|
||||||
|
|
||||||
es.index(dict(doc['metadata'], text=text),
|
es.index(dict(doc['metadata'], text=text),
|
||||||
settings.ELASTICSEARCH_INDEX,
|
settings.ELASTICSEARCH_INDEX,
|
||||||
settings.ELASTICSEARCH_DOC_TYPE,
|
settings.ELASTICSEARCH_DOC_TYPE,
|
||||||
id=doc_id)
|
id=doc_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.warning('error tracking %s', doc_id,
|
log.warning('error tracking %s', doc_id,
|
||||||
extra={'doc_class':doc['doc_class']},
|
extra={'doc_class':doc['doc_class']}, exc_info=True)
|
||||||
exc_info=True)
|
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user