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


Python ES.setup方法代码示例

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


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

示例1: run

# 需要导入模块: from nefertari.elasticsearch import ES [as 别名]
# 或者: from nefertari.elasticsearch.ES import setup [as 别名]
    def run(self, quiet=False):
        from nefertari.elasticsearch import ES
        ES.setup(self.settings)
        models_paths = split_strip(self.options.models)

        for path in models_paths:
            model = resolve(path)
            model_name = path.split('.')[-1]

            params = self.options.params or ''
            params = dict([
                [k, v[0]] for k, v in urlparse.parse_qs(params).items()
            ])
            params.setdefault('_limit', params.get('_limit', 10000))
            chunk_size = self.options.chunk or params['_limit']

            es = ES(source=model_name, index_name=self.options.index)
            query_set = model.get_collection(**params)
            documents = to_dicts(query_set)

            if self.options.force:
                es.index(documents, chunk_size=chunk_size)
            else:
                es.index_missing(documents, chunk_size=chunk_size)

        return 0
开发者ID:howaryoo,项目名称:nefertari,代码行数:28,代码来源:es.py

示例2: run

# 需要导入模块: from nefertari.elasticsearch import ES [as 别名]
# 或者: from nefertari.elasticsearch.ES import setup [as 别名]
    def run(self):
        ES.setup(self.settings)
        model_names = split_strip(self.options.models)

        for model_name in model_names:
            self.log.info('Processing model `{}`'.format(model_name))
            model = engine.get_document_cls(model_name)

            params = self.options.params or ''
            params = dict([
                [k, v[0]] for k, v in urllib.parse.parse_qs(params).items()
            ])
            params.setdefault('_limit', params.get('_limit', 10000))
            chunk_size = self.options.chunk or params['_limit']

            es = ES(source=model_name, index_name=self.options.index,
                    chunk_size=chunk_size)
            query_set = model.get_collection(**params)
            documents = to_dicts(query_set)

            if self.options.force:
                self.log.info('Recreating `{}` ES mapping'.format(model_name))
                es.delete_mapping()
                es.put_mapping(body=model.get_es_mapping())
                self.log.info('Indexing all `{}` documents'.format(
                    model_name))
                es.index(documents)
            else:
                self.log.info('Indexing missing `{}` documents'.format(
                    model_name))
                es.index_missing_documents(documents)

        return 0
开发者ID:mbijon,项目名称:nefertari,代码行数:35,代码来源:es.py

示例3: run

# 需要导入模块: from nefertari.elasticsearch import ES [as 别名]
# 或者: from nefertari.elasticsearch.ES import setup [as 别名]
 def run(self):
     ES.setup(self.settings)
     if self.options.recreate:
         self.recreate_index()
         models = engine.get_document_classes()
         model_names = [
             name for name, model in models.items()
             if getattr(model, '_index_enabled', False)]
     else:
         model_names = split_strip(self.options.models)
     self.index_models(model_names)
开发者ID:mkdir404,项目名称:nefertari,代码行数:13,代码来源:es.py


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