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

[FEATURE] Add a collapse method to opensearchpy.helpers.search.Search #408

Closed
qcoumes opened this issue Jun 10, 2023 · 7 comments
Closed
Labels
enhancement New feature or request

Comments

@qcoumes
Copy link
Contributor

qcoumes commented Jun 10, 2023

Is your feature request related to a problem?

The only way to currently add a collapse requirement to a search body is to use the extra() method. This is not the cleanest way because as mentioned in its docstring, extra() is mostly here for backward compatibility.

What solution would you like?

A solution would be to treat it the same way as sort:

  • Add a collapse() method opensearchpy.helpers.search.Search which creates and stores the dict in a self._collapse attribute.
  • Add self._collapse, if defined, in the body of the request in the to_dict() method.
@wbeckler
Copy link
Contributor

I can't see anything of this sort, but just in case I'm missing something, I'll ask: can you think of any case, in which this is implemented, in which we would inadvertently break someone's working code?

@qcoumes
Copy link
Contributor Author

qcoumes commented Jun 15, 2023

I think the addition of a method and a "private" attribute on Search should not break anybody's working code.

@wbeckler
Copy link
Contributor

okay, let's do it! @qcoumes if you want to take a crack at it, go for it.

@qcoumes
Copy link
Contributor Author

qcoumes commented Jun 22, 2023

I opened a PR: #409

@qcoumes
Copy link
Contributor Author

qcoumes commented Jun 28, 2023

Completed in #409

@qcoumes qcoumes closed this as completed Jun 28, 2023
@CorneeSean
Copy link
Contributor

Hello,
we just switched to AsyncOpenSearch and it seems that AsyncSearch lacks collapse feature altogether:
https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/_async/helpers/search.py

@dblock
Copy link
Member

dblock commented Sep 24, 2024

I reopened #769.

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

No branches or pull requests

4 participants