當前位置: 首頁>>代碼示例>>Python>>正文


Python ES.index_missing_documents方法代碼示例

本文整理匯總了Python中nefertari.elasticsearch.ES.index_missing_documents方法的典型用法代碼示例。如果您正苦於以下問題:Python ES.index_missing_documents方法的具體用法?Python ES.index_missing_documents怎麽用?Python ES.index_missing_documents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nefertari.elasticsearch.ES的用法示例。


在下文中一共展示了ES.index_missing_documents方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: index_models

# 需要導入模塊: from nefertari.elasticsearch import ES [as 別名]
# 或者: from nefertari.elasticsearch.ES import index_missing_documents [as 別名]
    def index_models(self, model_names):
        self.log.info('Indexing models documents')
        params = self.options.params or ''
        params = dict([[k, v[0]] for k, v in urllib.parse.parse_qs(params).items()])

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

            local_params = dict()
            local_params.update(params)

            if '_limit' not in local_params:
                limit = model.get_collection().count()
                local_params['_limit'] = limit

            chunk_size = int(self.options.chunk or local_params['_limit'])

            es = ES(source=model_name, index_name=self.options.index,
                    chunk_size=chunk_size)

            query_set = model.get_collection(**local_params)
            documents = to_indexable_dicts(query_set)
            self.log.info('Indexing missing `{}` documents'.format(
                model_name))
            es.index_missing_documents(documents)
開發者ID:oleduc,項目名稱:nefertari,代碼行數:28,代碼來源:es.py

示例2: run

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

        for model_name in model_names:
            model = engine.get_document_cls(model_name)

            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(documents, chunk_size=chunk_size)

        return 0
開發者ID:karthikmm,項目名稱:nefertari,代碼行數:27,代碼來源:es.py

示例3: run

# 需要導入模塊: from nefertari.elasticsearch import ES [as 別名]
# 或者: from nefertari.elasticsearch.ES import index_missing_documents [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

示例4: index_models

# 需要導入模塊: from nefertari.elasticsearch import ES [as 別名]
# 或者: from nefertari.elasticsearch.ES import index_missing_documents [as 別名]
    def index_models(self, model_names):
        self.log.info('Indexing models documents')
        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']

        for model_name in model_names:
            self.log.info('Processing model `{}`'.format(model_name))
            model = engine.get_document_cls(model_name)
            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)
            self.log.info('Indexing missing `{}` documents'.format(
                model_name))
            es.index_missing_documents(documents)
開發者ID:mkdir404,項目名稱:nefertari,代碼行數:21,代碼來源:es.py


注:本文中的nefertari.elasticsearch.ES.index_missing_documents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。