本文整理匯總了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())