-
Notifications
You must be signed in to change notification settings - Fork 803
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
feat: Add a collapse
method to elasticsearch_dsl.search.Search
#1649
Conversation
💚 CLA has been signed |
when will this be merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
You're missing s._collapse = self._collapse.copy()
in _clone()
. This was not visible in the unit test because .collapse()
was the last method you called. The following search made this bug visible:
s = (
Search()
.query("match", message="GET /search")
.collapse(field="user_id.keyword")
.sort("-bytes")
)
Can you please adjust test_collapse
to do something similar?
@qcoumes Is this something you want to tackle or should I go ahead and do it myself? |
Sorry, I did not see the notification. You can take over the PR if you want, I don't have the time to work on it right now. |
…in /Code/senescalade (#8) Bumps [elasticsearch-dsl](https://github.com/elasticsearch/elasticsearch-dsl-py) from 8.9.0 to 8.11.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/elasticsearch/elasticsearch-dsl-py/releases">elasticsearch-dsl's releases</a>.</em></p> <blockquote> <h2>8.11.0</h2> <ul> <li>Added support for Python 3.12 (<a href="https://redirect.github.com/elasticsearch/elasticsearch-dsl-py/issues/1680">#1680</a>)</li> <li>Added support for Search.collase() (<a href="https://redirect.github.com/elasticsearch/elasticsearch-dsl-py/issues/1649">#1649</a>, contributed by <a href="https://github.com/qcoumes"><code>@qcoumes</code></a>)</li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/elastic/elasticsearch-dsl-py/blob/main/Changelog.rst">elasticsearch-dsl's changelog</a>.</em></p> <blockquote> <h2>8.11.0 (2023-11-13)</h2> <ul> <li>Added support for Python 3.12 (<code>[#1680](https://github.com/elasticsearch/elasticsearch-dsl-py/issues/1680)</code>_)</li> <li>Added support for Search.collase() (<code>[#1649](https://github.com/elasticsearch/elasticsearch-dsl-py/issues/1649)</code><em>, contributed by <code>@qcoumes</code></em>)</li> </ul> <p>.. _<a href="https://github.com/qcoumes"><code>@qcoumes</code></a>: <a href="https://github.com/qcoumes">https://github.com/qcoumes</a> .. _<a href="https://redirect.github.com/elasticsearch/elasticsearch-dsl-py/issues/1680">#1680</a>: <a href="https://redirect.github.com/elastic/elasticsearch-dsl-py/pull/1680">elastic/elasticsearch-dsl-py#1680</a> .. _<a href="https://redirect.github.com/elasticsearch/elasticsearch-dsl-py/issues/1649">#1649</a>: <a href="https://redirect.github.com/elastic/elasticsearch-dsl-py/pull/1649">elastic/elasticsearch-dsl-py#1649</a></p> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/elastic/elasticsearch-dsl-py/commit/ecf2e156a1e13109b7cd432300960353f8df7ab1"><code>ecf2e15</code></a> Release 8.11.0</li> <li><a href="https://github.com/elastic/elasticsearch-dsl-py/commit/333aa5ad719333d4e19f0dd1cc86e86821bec1d0"><code>333aa5a</code></a> Document Search.collapse() (<a href="https://redirect.github.com/elasticsearch/elasticsearch-dsl-py/issues/1681">#1681</a>)</li> <li><a href="https://github.com/elastic/elasticsearch-dsl-py/commit/1a247faf2979908d9639091af2dbfcac13f1ef64"><code>1a247fa</code></a> feat: Add a <code>collapse</code> method to <code>elasticsearch_dsl.search.Search</code> (<a href="https://redirect.github.com/elasticsearch/elasticsearch-dsl-py/issues/1649">#1649</a>)</li> <li><a href="https://github.com/elastic/elasticsearch-dsl-py/commit/0e94780a603ebdd8bcc6d85b7e775f558711439e"><code>0e94780</code></a> Add support for Python 3.12 (<a href="https://redirect.github.com/elasticsearch/elasticsearch-dsl-py/issues/1680">#1680</a>)</li> <li><a href="https://github.com/elastic/elasticsearch-dsl-py/commit/82418c01b4b0350636877e81e105164b8fcf289c"><code>82418c0</code></a> Fix backport GitHub Action for forks (<a href="https://redirect.github.com/elasticsearch/elasticsearch-dsl-py/issues/1674">#1674</a>)</li> <li><a href="https://github.com/elastic/elasticsearch-dsl-py/commit/bde8e10cbdefca654f402e077d8c885d182384f1"><code>bde8e10</code></a> Add 8.9.0 release to changelog on main (<a href="https://redirect.github.com/elasticsearch/elasticsearch-dsl-py/issues/1671">#1671</a>)</li> <li><a href="https://github.com/elastic/elasticsearch-dsl-py/commit/47a5d7296ef570a4ad2d28b3378b6520416f6013"><code>47a5d72</code></a> Fix missing jQuery in docs (<a href="https://redirect.github.com/elasticsearch/elasticsearch-dsl-py/issues/1673">#1673</a>)</li> <li><a href="https://github.com/elastic/elasticsearch-dsl-py/commit/3073976e94929a3c39bd87a5753b5d4031ec6725"><code>3073976</code></a> Update docs before 8.9.0 release (<a href="https://redirect.github.com/elasticsearch/elasticsearch-dsl-py/issues/1669">#1669</a>)</li> <li><a href="https://github.com/elastic/elasticsearch-dsl-py/commit/29ca74d5b60b31d0d1d48ff4da5ada3298399b0b"><code>29ca74d</code></a> Fix Read the Docs build (<a href="https://redirect.github.com/elasticsearch/elasticsearch-dsl-py/issues/1668">#1668</a>)</li> <li>See full diff in <a href="https://github.com/elasticsearch/elasticsearch-dsl-py/compare/v8.9.0...v8.11.0">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=elasticsearch-dsl&package-manager=pip&previous-version=8.9.0&new-version=8.11.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details>
This PR adds a
collapse
method toelasticsearch_dsl.search.Search
which allows adding a collapse requirement to a query without the need for.extra()
orupdate_from_dict()
.This is achieved similarly to how
sort()
is done.Issues Resolved
#1215