本文整理汇总了Python中mkt.webapps.models.Webapp.indexing_transformer方法的典型用法代码示例。如果您正苦于以下问题:Python Webapp.indexing_transformer方法的具体用法?Python Webapp.indexing_transformer怎么用?Python Webapp.indexing_transformer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mkt.webapps.models.Webapp
的用法示例。
在下文中一共展示了Webapp.indexing_transformer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index_webapps
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import indexing_transformer [as 别名]
def index_webapps(ids, **kw):
task_log.info('Indexing apps %s-%s. [%s]' % (ids[0], ids[-1], len(ids)))
index = kw.pop('index', WebappIndexer.get_index())
# Note: If reindexing is currently occurring, `get_indices` will return
# more than one index.
indices = get_indices(index)
es = WebappIndexer.get_es(urls=settings.ES_URLS)
qs = Webapp.indexing_transformer(Webapp.uncached.filter(id__in=ids))
for obj in qs:
doc = WebappIndexer.extract_document(obj.id, obj)
for idx in indices:
WebappIndexer.index(doc, id_=obj.id, es=es, index=idx)
示例2: run_indexing
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import indexing_transformer [as 别名]
def run_indexing(cls, ids, ES, index=None, **kw):
"""Override run_indexing to use app transformers."""
from mkt.webapps.models import Webapp
sys.stdout.write("Indexing %s webapps\n" % len(ids))
qs = Webapp.indexing_transformer(Webapp.with_deleted.no_cache().filter(id__in=ids))
docs = []
for obj in qs:
try:
docs.append(cls.extract_document(obj.id, obj=obj))
except Exception as e:
sys.stdout.write("Failed to index webapp {0}: {1}\n".format(obj.id, e))
WebappIndexer.bulk_index(docs, es=ES, index=index or cls.get_index())
示例3: _get_doc
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import indexing_transformer [as 别名]
def _get_doc(self):
qs = Webapp.indexing_transformer(
Webapp.uncached.filter(id__in=[self.app.pk]))
obj = qs[0]
return obj, WebappIndexer.extract_document(obj.pk, obj)