Skip to content

Clarify that the FT.SEARCH count is the total number of matching documents - #3817

Open
raz-mon wants to merge 2 commits into
mainfrom
ft-search-hits-clarification
Open

Clarify that the FT.SEARCH count is the total number of matching documents#3817
raz-mon wants to merge 2 commits into
mainfrom
ft-search-hits-clarification

Conversation

@raz-mon

@raz-mon raz-mon commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

What

The first element of the FT.SEARCH reply (total_results in RESP3) was documented only as "the total number of results", which readers reasonably take to mean the number of documents in the reply. It is the total number of documents that match the query, independent of LIMIT.

Changes to content/commands/ft.search.md

  • Return and Return information (RESP2 and RESP3) now say "the total number of documents that match the query".
  • Added a short paragraph distinguishing that total from the LIMIT-bounded document list (default 0 10), plus an example and a pointer to LIMIT 0 0 for the total alone.
  • Reworded the existing notes for consistency, including the expired/updated-key note.
  • Added a note on the one case where the number is not a full match count: with the DIALECT 4 / WITHOUTCOUNT sorting optimizations the query stops once it has collected the LIMIT window, so the reported number is capped there; WITHCOUNT on SORTBY restores an accurate count. Verified against QOptimizer_UpdateTotalResults in RediSearch, which is applied only when the query is optimized.

Scope is deliberately limited to FT.SEARCH. FT.AGGREGATE and FT.HYBRID use the same "total number of results" phrasing but their count semantics differ, so they are left for a separate change.

Review wording from @dwdougherty applied in 41e7e18.

🤖 Generated with Claude Code

The first element of the FT.SEARCH reply (total_results in RESP3) was
described only as "the total number of results", which reads as the
number of documents in the reply. It is the number of hits: every
document that matches the query, independent of LIMIT.

- Say "number of hits, that is, the number of documents that match the
  query" in the Return and Return information sections.
- Contrast it with the LIMIT-bounded document list, with an example and
  a pointer to LIMIT 0 0 for the count alone.
- Note the one case where the number is not a full match count: the
  DIALECT 4 / WITHOUTCOUNT sorting optimizations cap it at the LIMIT
  window (QOptimizer_UpdateTotalResults in RediSearch), and WITHCOUNT
  restores an accurate count.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Aug 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🧠 Redis Memory

Found 6 related items from repository history (1 new this commit):

Memory updated at 41e7e18

@raz-mon
raz-mon requested a review from dwdougherty August 16, 2026 15:51
@dwdougherty dwdougherty self-assigned this Aug 17, 2026
@dwdougherty dwdougherty added dev oss Redis Open Source and removed oss Redis Open Source labels Aug 17, 2026

@dwdougherty dwdougherty left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @raz-mon. Thank you for this PR. I needed to clean up the language a bit (remove "hits", etc.).

Comment thread content/commands/ft.search.md Outdated
Comment thread content/commands/ft.search.md Outdated
Comment thread content/commands/ft.search.md Outdated
Comment thread content/commands/ft.search.md
Drop "hits" in favor of "documents that match the query" throughout the
Return and Return information sections, and take David's phrasing for
the intro paragraphs, the three notes, and the RESP2/RESP3 reply
descriptions verbatim.

Kept the inline code formatting on LIMIT / 0 10 / LIMIT 0 0, which the
suggestion text dropped only because it was typed as plain prose; the
rest of the page and David's other suggestions backtick those tokens.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@raz-mon raz-mon changed the title Clarify that the FT.SEARCH count is the number of hits Clarify that the FT.SEARCH count is the total number of matching documents Aug 18, 2026
@raz-mon
raz-mon requested a review from dwdougherty August 18, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants