-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Updated: Added logic to implement Interval Faceting (Solr only). #1934
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
base: master
Are you sure you want to change the base?
Conversation
To deal with the test fail, is it worth refactoring the What about increasing the maximum number of allowed arguments in pylint? |
Go ahead and increase |
|
||
Adds interval faceting to a query for the provided field. You provide the field | ||
(from one of the ``SearchIndex`` classes) you like to facet on and an array of | ||
``intervals``. This is currently supported only when using Solr (ver 4.10+) |
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.
Reviewers: Should we drop support for Solr < v4.10 or should this code detect that the Solr version is >= 4.10?
We first have to make the tests with solr pass again on master branch before being able to accept new functionalities related to solr. |
@claudep Totally understand, I was just updating my branch and figured it would be better to get this into the main release instead of being stuck on a fork. Hopefully you can working the solr testing issue, that's beyond me. |
And beyond me, too 😭 Your intent to integrate your patch in the main branch is really appreciated, thanks! |
@claudep Is the testing updated and ready to consider adding this PR yet? |
Please rebase so all tests will pass. |
for more information, see https://pre-commit.ci
Increase max_args
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
https://pypi.org/project/Django https://www.djangoproject.com/weblog/2023/dec/04/django-50-released > Django 4.1 has reached the end of extended support. The final security release ([4.1.13](https://docs.djangoproject.com/en/stable/releases/4.1.13/)) was issued on November 1st. All Django 4.1 users are encouraged to [upgrade](https://docs.djangoproject.com/en/dev/howto/upgrade-version/) to Django 4.2 or later. https://docs.djangoproject.com/en/5.0/releases/5.0 > Django 5.0 supports Python 3.10, 3.11, and 3.12. https://docs.djangoproject.com/en/5.0/faq/install/#what-python-version-can-i-use-with-django
* pre-commit: format files with prettier * yaml indent_size = 2
* Migrate away from pkg_resources Using pkg_resources as an API is deprecated. Migrate functionality to their importlib and packaging equivalents. Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net> * Add packaging to requirements Required for packaging.version after the removal of pkg_resources. Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net> --------- Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
…jango-haystack#1937) Co-authored-by: me <me@gmail.com>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.13 → v0.1.14](astral-sh/ruff-pre-commit@v0.1.13...v0.1.14) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 23.12.1 → 24.1.1](psf/black@23.12.1...24.1.1) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Keep GitHub Actions up to date with GitHub's Dependabot * https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot * https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com>
Bumps the github-actions group with 5 updates: | Package | From | To | | --- | --- | --- | | [actions/checkout](https://github.com/actions/checkout) | `3` | `4` | | [github/codeql-action](https://github.com/github/codeql-action) | `1` | `3` | | [actions/setup-python](https://github.com/actions/setup-python) | `4` | `5` | | [actions/upload-artifact](https://github.com/actions/upload-artifact) | `3` | `4` | | [actions/download-artifact](https://github.com/actions/download-artifact) | `3` | `4` | Updates `actions/checkout` from 3 to 4 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v3...v4) Updates `github/codeql-action` from 1 to 3 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@v1...v3) Updates `actions/setup-python` from 4 to 5 - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@v4...v5) Updates `actions/upload-artifact` from 3 to 4 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@v3...v4) Updates `actions/download-artifact` from 3 to 4 - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](actions/download-artifact@v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: actions/download-artifact dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.14 → v0.2.0](astral-sh/ruff-pre-commit@v0.1.14...v0.2.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.0 → v0.2.1](astral-sh/ruff-pre-commit@v0.2.0...v0.2.1) - [github.com/psf/black: 24.1.1 → 24.2.0](psf/black@24.1.1...24.2.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.1 → v0.4.2](astral-sh/ruff-pre-commit@v0.4.1...v0.4.2) - [github.com/psf/black: 24.4.0 → 24.4.2](psf/black@24.4.0...24.4.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* django-upgrade --target-version=5.0 **/*.py * djLint: Use HTTPS for external links.
updates: - [github.com/adamchainz/django-upgrade: 1.15.0 → 1.16.0](adamchainz/django-upgrade@1.15.0...1.16.0) - [github.com/astral-sh/ruff-pre-commit: v0.4.2 → v0.4.3](astral-sh/ruff-pre-commit@v0.4.2...v0.4.3) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: - [github.com/adamchainz/django-upgrade: 1.16.0 → 1.17.0](adamchainz/django-upgrade@1.16.0...1.17.0) - [github.com/astral-sh/ruff-pre-commit: v0.4.3 → v0.4.4](astral-sh/ruff-pre-commit@v0.4.3...v0.4.4)
updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.4 → v0.4.5](astral-sh/ruff-pre-commit@v0.4.4...v0.4.5) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: - [github.com/adamchainz/django-upgrade: 1.17.0 → 1.18.0](adamchainz/django-upgrade@1.17.0...1.18.0) - [github.com/astral-sh/ruff-pre-commit: v0.4.5 → v0.4.7](astral-sh/ruff-pre-commit@v0.4.5...v0.4.7) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.7 → v0.4.8](astral-sh/ruff-pre-commit@v0.4.7...v0.4.8) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.8 → v0.4.9](astral-sh/ruff-pre-commit@v0.4.8...v0.4.9) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.9 → v0.4.10](astral-sh/ruff-pre-commit@v0.4.9...v0.4.10) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: - [github.com/adamchainz/django-upgrade: 1.18.0 → 1.19.0](adamchainz/django-upgrade@1.18.0...1.19.0) - [github.com/astral-sh/ruff-pre-commit: v0.4.10 → v0.5.0](astral-sh/ruff-pre-commit@v0.4.10...v0.5.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.0 → v0.5.1](astral-sh/ruff-pre-commit@v0.5.0...v0.5.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.1 → v0.5.2](astral-sh/ruff-pre-commit@v0.5.1...v0.5.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: - [github.com/adamchainz/django-upgrade: 1.19.0 → 1.20.0](adamchainz/django-upgrade@1.19.0...1.20.0) - [github.com/astral-sh/ruff-pre-commit: v0.5.2 → v0.5.4](astral-sh/ruff-pre-commit@v0.5.2...v0.5.4) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.4 → v0.5.5](astral-sh/ruff-pre-commit@v0.5.4...v0.5.5) * test.yml: sudo apt update --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com>
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.5 → v0.5.6](astral-sh/ruff-pre-commit@v0.5.5...v0.5.6) - [github.com/psf/black: 24.4.2 → 24.8.0](psf/black@24.4.2...24.8.0) * .pre-commit-config.yaml: ci: autoupdate_schedule: monthly --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.6 → v0.6.3](astral-sh/ruff-pre-commit@v0.5.6...v0.6.3) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* GitHub Actions: Add Python 3.13 to the testing * elastic-version: ["7.17.12"]
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/adamchainz/django-upgrade: 1.20.0 → 1.23.1](adamchainz/django-upgrade@1.20.0...1.23.1) - [github.com/astral-sh/ruff-pre-commit: v0.6.3 → v0.9.9](astral-sh/ruff-pre-commit@v0.6.3...v0.9.9) - [github.com/PyCQA/isort: 5.13.2 → 6.0.1](PyCQA/isort@5.13.2...6.0.1) - [github.com/psf/black: 24.8.0 → 25.1.0](psf/black@24.8.0...25.1.0) - [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](pre-commit/pre-commit-hooks@v4.6.0...v5.0.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/adamchainz/django-upgrade: 1.23.1 → 1.24.0](adamchainz/django-upgrade@1.23.1...1.24.0) - [github.com/astral-sh/ruff-pre-commit: v0.9.9 → v0.11.4](astral-sh/ruff-pre-commit@v0.9.9...v0.11.4) * facet_types.update(dict.fromkeys(facets, "fields")) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com>
I rebased it, but the merge commits might have made the PR a mess. If it's too much of a mess and it would be better to close and create a new one let me know. |
This is just a re-based version of #1510
Per stmos' original notes:
This currently only works with Solr backend (>4.10).
More details about interval faceting can be found at: Solr - Interval Faceting
Example:
intervals = ['[0,100]', '(100, *]']
sqs = SearchQuerySet()
sqs.interval_facet('price', intervals=intervals)
Key replacement is supported as well:
sqs.interval_facet('price', intervals=['{!key=cheap}[0, 100]', '{!key=expensive}[100, *)']).facet_counts()
Output:
{u'dates': {}, u'fields': {}, u'intervals': {'price': {u'cheap': 4, u'expensive': 47}}, u'queries': {}}
Syntax is explained at the URL posted above.
There is no need to specify the "facet=true" when defining the search index for the fields you want to use for interval faceting.
Only requirement is that fields used for Interval Faceting must have “docValues” enabled (not required for Solr 5.20 and above)
@stmos