Skip to content

Issue #1992: Implemented handling for track_total_hits in the Elasticsearch search backend. #1993

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

nikolaysm
Copy link
Contributor

@nikolaysm nikolaysm commented Aug 11, 2024

Issue #1992 (comment)

  • Implemented handling for track_total_hits in the Elasticsearch search backend.
  • Supports bool values (True/False) and int values.
  • Added a warning for invalid track_total_hits values.
  • Ensured the parameter is only added to search kwargs when valid.
  • Documented the HAYSTACK_TRACK_TOTAL_HITS setting in the search backend configuration.
  • Implemented test to verify the correct handling of. track_total_hits in Elasticsearch 7.

nikolaysm and others added 7 commits August 9, 2024 13:58
Add HAYSTACK_TRACK_TOTAL_HITS Setting to Constants

- Added `HAYSTACK_TRACK_TOTAL_HITS` to `haystack/constants.py`.
- This setting allows configuration of the `track_total_hits` parameter in Elasticsearch queries.
- Valid options are of type `bool` or `int`.
- Default value is `False`, meaning the `track_total_hits` parameter will be omitted by default.
Support track_total_hits Handling in ElasticsearchSearchBackend

- Implemented handling for `track_total_hits` in the Elasticsearch search backend.
- Supports `bool` values (True/False) and `int` values.
- Added a warning for invalid `track_total_hits` values.
- Ensured the parameter is only added to search kwargs when valid.
…Setting

- Documented the `HAYSTACK_TRACK_TOTAL_HITS` setting in the search backend configuration.
- Explained the impact of setting values: `True`, `int`, and `False`.
- Included examples for configuring `HAYSTACK_TRACK_TOTAL_HITS`.
- Default behavior is noted as `False`, meaning the `track_total_hits` parameter is omitted by default.
Removed unnecessary blank line and replaced search_kwargs with kwargs, to resolve automated test errors
…ndTrackTotalHitsTestCase

Implemented  to verify the correct handling of  in Elasticsearch 7.
Relocated the  logic from  to  as this feature is only supported in Elasticsearch 7 and higher.
@nikolaysm
Copy link
Contributor Author

Hi @acdha , @cclauss ,

Could you please review my pull request for Django-Haystack? It addresses issue #1992.

Thanks

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

Successfully merging this pull request may close these issues.

2 participants