Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msearch_template fails on request #2127

Closed
bashpound opened this issue Dec 22, 2022 · 2 comments
Closed

msearch_template fails on request #2127

bashpound opened this issue Dec 22, 2022 · 2 comments

Comments

@bashpound
Copy link

bashpound commented Dec 22, 2022

Describe the feature:

Elasticsearch version (bin/elasticsearch --version):
7.17.8

elasticsearch-py version (elasticsearch.__versionstr__):
7.17.0

Please make sure the major version matches the Elasticsearch server you are running.

b = [{ "index": "some-index*" },
     { "id": "template_id", "params": { "keyword": "key"}},
     { "index": "some-other-index*" },
     { "id": "template_id2", "params": { "keyword": "key"}}]

es.msearch_template(body=b)  // OR
es.msearch_template(search_templates=b) 

// result in the same error below:

---------------------------------------------------------------------------
BadRequestError                           Traceback (most recent call last)
<ipython-input-75-a87865ceb6d2> in <module>
      5 
      6 
----> 7 es.msearch_template(body=b)

\python\python38\lib\site-packages\elasticsearch\_sync\client\utils.py in wrapped(*args, **kwargs)
    402                         pass
    403 
--> 404             return api(*args, **kwargs)
    405 
    406         return wrapped  # type: ignore[return-value]

\python\python38\lib\site-packages\elasticsearch\_sync\client\__init__.py in msearch_template(self, search_templates, index, ccs_minimize_roundtrips, error_trace, filter_path, human, max_concurrent_searches, pretty, rest_total_hits_as_int, search_type, typed_keys)
   2646             "content-type": "application/x-ndjson",
   2647         }
-> 2648         return self.perform_request(  # type: ignore[return-value]
   2649             "POST", __path, params=__query, headers=__headers, body=__body
   2650         )

\python\python38\lib\site-packages\elasticsearch\_sync\client\_base.py in perform_request(self, method, path, params, headers, body)
    319                     pass
    320 
--> 321             raise HTTP_EXCEPTIONS.get(meta.status, ApiError)(
    322                 message=message, meta=meta, body=resp_body
    323             )

BadRequestError: BadRequestError(400, 'action_request_validation_exception', 'Validation Failed: 1: no requests added;')


@sethmlarson
Copy link
Contributor

I'm not able to reproduce your exact error, are you able to try sending the same request via curl to see if this is an issue with the API call itself rather than the client? The msearch_template API being generated doesn't look like it's doing anything funky when comparing it to the API documentation.

@sethmlarson
Copy link
Contributor

Closing this until we receive more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants