django-haystack / django-haystack/django-haystack

Add Support for "track_total_hits" to Accurately Track Total Hits Above 10K

Open
#1,992 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.7k
Forks
1.3k
Avg merge
3h 18m
Merged PRs (30d)
3

Description

Issue:
Django Haystack currently does not support the track_total_hits parameter, leading to inaccurate hit counts when the total exceeds 10,000 (due to Elasticsearch's default limit).

Suggestion:
We can add an option in the Elasticsearch backend to enable track_total_hits, allowing users to get accurate total hit counts above 10,000.

if settings.TRACK_TOTAL_HITS: 
    search_kwargs["track_total_hits"] = "true"

This could be added within the search method of elasticsearch_backend.py, allowing users to enable accurate hit tracking.

Reference:
Elasticsearch: Track Total Hits

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in haystack/backends/elasticsearch_backend.py at the search method linked in the issue, then read the Elasticsearch Track Total Hits reference. Determine how the backend option should be exposed and verified; done means users can enable accurate total hit counts beyond 10,000.

Written by the indexing model from the issue text.

Assessment

Tech stack
elasticsearch, python
Domain
backend, search
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.