本文整理汇总了Python中olympia.addons.indexers.AddonIndexer.get_index_alias方法的典型用法代码示例。如果您正苦于以下问题:Python AddonIndexer.get_index_alias方法的具体用法?Python AddonIndexer.get_index_alias怎么用?Python AddonIndexer.get_index_alias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类olympia.addons.indexers.AddonIndexer
的用法示例。
在下文中一共展示了AddonIndexer.get_index_alias方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from olympia.addons.indexers import AddonIndexer [as 别名]
# 或者: from olympia.addons.indexers.AddonIndexer import get_index_alias [as 别名]
def search(self):
self.reindex(Addon)
qs = Search(using=amo.search.get_es(),
index=AddonIndexer.get_index_alias(),
doc_type=AddonIndexer.get_doctype_name())
return qs.filter('term', id=self.addon.pk).execute()[0]
示例2: find_inconsistencies_between_es_and_db
# 需要导入模块: from olympia.addons.indexers import AddonIndexer [as 别名]
# 或者: from olympia.addons.indexers.AddonIndexer import get_index_alias [as 别名]
def find_inconsistencies_between_es_and_db(ids, **kw):
length = len(ids)
log.info(
'Searching for inconsistencies between db and es %d-%d [%d].',
ids[0], ids[-1], length)
db_addons = Addon.unfiltered.in_bulk(ids)
es_addons = Search(
doc_type=AddonIndexer.get_doctype_name(),
index=AddonIndexer.get_index_alias(),
using=amo.search.get_es()).filter('ids', values=ids)[:length].execute()
es_addons = es_addons
db_len = len(db_addons)
es_len = len(es_addons)
if db_len != es_len:
log.info('Inconsistency found: %d in db vs %d in es.',
db_len, es_len)
for result in es_addons.hits.hits:
pk = result['_source']['id']
db_modified = db_addons[pk].modified.isoformat()
es_modified = result['_source']['modified']
if db_modified != es_modified:
log.info('Inconsistency found for addon %d: '
'modified is %s in db vs %s in es.',
pk, db_modified, es_modified)
db_status = db_addons[pk].status
es_status = result['_source']['status']
if db_status != es_status:
log.info('Inconsistency found for addon %d: '
'status is %s in db vs %s in es.',
pk, db_status, es_status)
示例3: serialize
# 需要导入模块: from olympia.addons.indexers import AddonIndexer [as 别名]
# 或者: from olympia.addons.indexers.AddonIndexer import get_index_alias [as 别名]
def serialize(self):
self.reindex(Addon)
qs = Search(using=amo.search.get_es(),
index=AddonIndexer.get_index_alias(),
doc_type=AddonIndexer.get_doctype_name())
obj = qs.filter('term', id=self.addon.pk).execute()[0]
with self.assertNumQueries(0):
serializer = ESAddonSerializer(context={'request': self.request})
result = serializer.to_representation(obj)
return result
示例4: test_mapping
# 需要导入模块: from olympia.addons.indexers import AddonIndexer [as 别名]
# 或者: from olympia.addons.indexers.AddonIndexer import get_index_alias [as 别名]
def test_mapping(self):
"""Compare actual mapping in ES with the one the indexer returns, once
an object has been indexed.
We don't want dynamic mapping for addons (too risky), so the two
mappings should be equal."""
self.reindex(Addon)
indexer = AddonIndexer()
doc_name = indexer.get_doctype_name()
real_index_name = self.index_names[SearchMixin.ES_ALIAS_KEY]
mappings = self.es.indices.get_mapping(
indexer.get_index_alias())[real_index_name]['mappings']
actual_properties = mappings[doc_name]['properties']
indexer_properties = indexer.get_mapping()[doc_name]['properties']
assert set(actual_properties.keys()) == set(indexer_properties.keys())