当前位置: 首页>>代码示例>>Python>>正文


Python WebappIndexer.get_index方法代码示例

本文整理汇总了Python中mkt.webapps.models.WebappIndexer.get_index方法的典型用法代码示例。如果您正苦于以下问题:Python WebappIndexer.get_index方法的具体用法?Python WebappIndexer.get_index怎么用?Python WebappIndexer.get_index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mkt.webapps.models.WebappIndexer的用法示例。


在下文中一共展示了WebappIndexer.get_index方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tearDown

# 需要导入模块: from mkt.webapps.models import WebappIndexer [as 别名]
# 或者: from mkt.webapps.models.WebappIndexer import get_index [as 别名]
 def tearDown(self):
     # Cleanup to remove these from the index.
     self.app1.delete()
     self.app2.delete()
     unindex_webapps([self.app1.id, self.app2.id])
     # Required to purge the suggestions data structure. In Lucene, a
     # document is not deleted from a segment, just marked as deleted.
     WebappIndexer.get_es().optimize(WebappIndexer.get_index(), only_expunge_deletes=True)
开发者ID:KKcorps,项目名称:zamboni,代码行数:10,代码来源:test_api.py

示例2: index_webapps

# 需要导入模块: from mkt.webapps.models import WebappIndexer [as 别名]
# 或者: from mkt.webapps.models.WebappIndexer import get_index [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)
开发者ID:MikeLing,项目名称:zamboni,代码行数:16,代码来源:tasks.py

示例3: unindex_webapps

# 需要导入模块: from mkt.webapps.models import WebappIndexer [as 别名]
# 或者: from mkt.webapps.models.WebappIndexer import get_index [as 别名]
def unindex_webapps(ids, **kw):
    task_log.info("Un-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)
    for id_ in ids:
        for idx in indices:
            try:
                WebappIndexer.unindex(id_=id_, es=es, index=idx)
            except ElasticHttpNotFoundError:
                # Ignore if it's not there.
                task_log.info(u"[Webapp:%s] Unindexing app but not found in index" % id_)
开发者ID:jlongster,项目名称:zamboni,代码行数:18,代码来源:tasks.py

示例4: get

# 需要导入模块: from mkt.webapps.models import WebappIndexer [as 别名]
# 或者: from mkt.webapps.models.WebappIndexer import get_index [as 别名]
    def get(self, request, *args, **kwargs):
        limit = request.GET.get("limit", 5)
        es_query = {
            "apps": {"completion": {"field": "name_suggest", "size": limit}, "text": request.GET.get("q", "").strip()}
        }

        results = S(WebappIndexer).get_es().send_request("GET", [WebappIndexer.get_index(), "_suggest"], body=es_query)

        if "apps" in results:
            data = results["apps"][0]["options"]
        else:
            data = []
        serializer = self.get_serializer(data)
        # This returns a JSON list. Usually this is a bad idea for security
        # reasons, but we don't include any user-specific data, it's fully
        # anonymous, so we're fine.
        return HttpResponse(json.dumps(serializer.data), content_type="application/x-rocketbar+json")
开发者ID:unghost,项目名称:zamboni,代码行数:19,代码来源:api.py

示例5: get

# 需要导入模块: from mkt.webapps.models import WebappIndexer [as 别名]
# 或者: from mkt.webapps.models.WebappIndexer import get_index [as 别名]
    def get(self, request, *args, **kwargs):
        limit = request.GET.get('limit', 5)
        es_query = {
            'apps': {
                'completion': {'field': 'name_suggest', 'size': limit},
                'text': request.GET.get('q', '').strip()
            }
        }

        results = S(WebappIndexer).get_es().send_request(
            'GET', [WebappIndexer.get_index(), '_suggest'], body=es_query)

        if 'apps' in results:
            data = results['apps'][0]['options']
        else:
            data = []
        serializer = self.get_serializer(data)
        # This returns a JSON list. Usually this is a bad idea for security
        # reasons, but we don't include any user-specific data, it's fully
        # anonymous, so we're fine.
        return HttpResponse(json.dumps(serializer.data),
                            content_type='application/x-rocketbar+json')
开发者ID:aspes,项目名称:zamboni,代码行数:24,代码来源:views.py

示例6: handle

# 需要导入模块: from mkt.webapps.models import WebappIndexer [as 别名]
# 或者: from mkt.webapps.models.WebappIndexer import get_index [as 别名]
    def handle(self, *args, **kwargs):
        index = WebappIndexer.get_index()
        doctype = WebappIndexer.get_mapping_type_name()
        es = WebappIndexer.get_es()

        apps = Webapp.objects.values_list('id', flat=True)

        missing_ids = []

        for app in apps:
            try:
                res = es.get(index, doctype, app, fields='id')
            except ElasticHttpNotFoundError:
                # App doesn't exist in our index, add it to `missing_ids`.
                missing_ids.append(app)

        if missing_ids:
            sys.stdout.write('Adding %s doc(s) to the index.'
                             % len(missing_ids))
            index_webapps.delay(missing_ids)
        else:
            sys.stdout.write('No docs missing from index.')
开发者ID:AALEKH,项目名称:zamboni,代码行数:24,代码来源:fixup_mkt_index.py

示例7: setUp

# 需要导入模块: from mkt.webapps.models import WebappIndexer [as 别名]
# 或者: from mkt.webapps.models.WebappIndexer import get_index [as 别名]
 def setUp(self):
     super(TestFixupCommand, self).setUp()
     self.index = WebappIndexer.get_index()
     self.doctype = WebappIndexer.get_mapping_type_name()
     self.es = WebappIndexer.get_es()
     self.app = Webapp.objects.get(pk=337141)
开发者ID:AALEKH,项目名称:zamboni,代码行数:8,代码来源:test_commands.py

示例8: test_index

# 需要导入模块: from mkt.webapps.models import WebappIndexer [as 别名]
# 或者: from mkt.webapps.models.WebappIndexer import get_index [as 别名]
 def test_index(self):
     with self.settings(ES_INDEXES={'webapp': 'apps'}):
         eq_(WebappIndexer.get_index(), 'apps')
开发者ID:kmaglione,项目名称:zamboni,代码行数:5,代码来源:test_models.py


注:本文中的mkt.webapps.models.WebappIndexer.get_index方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。