python elasticsearch

报错: elasticsearch.exceptions.RequestError: RequestError(400, 'parse_exception', 'request body or source parameter is required')
修改: Lib\site-packages\elasticsearch\client_init_.py: 把原先的return 注释掉.msearch 入参没有doc_type 需要加上

    def msearch(self, body, index=None, doc_type=None, params=None):
        """
        Execute several search requests within the same API.
        `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html>`_

        :arg body: The request definitions (metadata-search request definition
            pairs), separated by newlines
        :arg index: A comma-separated list of index names to use as default
        :arg doc_type: A comma-separated list of document types to use as
            default
        :arg max_concurrent_searches: Controls the maximum number of concurrent
            searches the multi search api will execute
        :arg pre_filter_shard_size: A threshold that enforces a pre-filter
            roundtrip to prefilter search shards based on query rewriting if
            the number of shards the search request expands to exceeds the
            threshold. This filter roundtrip can limit the number of shards
            significantly if for instance a shard can not match any documents
            based on it's rewrite method ie. if date filters are mandatory to
            match but the shard bounds and the query are disjoint., default 128
        :arg search_type: Search operation type, valid choices are:
            'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch',
            'dfs_query_and_fetch'
        :arg typed_keys: Specify whether aggregation and suggester names should
            be prefixed by their respective types in the response
        """
        if body in SKIP_IN_PATH:
            raise ValueError("Empty value passed for a required argument 'body'.")
        # return self.transport.perform_request('GET', _make_path(index,
        #     doc_type, '_msearch'), params=params, body=self._bulk_body(body),
        #     headers={'content-type': 'application/x-ndjson'})
        return self.transport.perform_request('POST', _make_path(index,
                                                                doc_type, '_msearch'), params=params,
                                              body=self._bulk_body(body),
                                              headers={'content-type': 'application/x-ndjson','kbn-version': '5.5.2'})

posted on 2019-12-11 14:32  游荡的鱼  阅读(807)  评论(0编辑  收藏  举报

导航