Skip to content

MOD-11858: Support subquery count in FT.HYBRID#7770

Merged
Itzikvaknin merged 6 commits intomasterfrom
ivaknin_add_count_for_subqueries_in_ft_hybrid
Dec 22, 2025
Merged

MOD-11858: Support subquery count in FT.HYBRID#7770
Itzikvaknin merged 6 commits intomasterfrom
ivaknin_add_count_for_subqueries_in_ft_hybrid

Conversation

@Itzikvaknin
Copy link
Collaborator

@Itzikvaknin Itzikvaknin commented Dec 14, 2025

Describe the changes in the pull request

Add support for subquery count in FT.HYBRID - preparation for future multiple (>2) subqueries support.

A clear and concise description of what the PR is solving, including:

  1. Current:
    Only FT.HYBRID SEARCH <search_query> VSIM <vector_query> is valid.

  2. Change:
    Both FT.HYBRID SEARCH <search_query> VSIM <vector_query> and
    FT.HYBRID count SEARCH <search_query> VSIM <vector_query> are valid.
    Currently, only two subqueries are supported, and they must appear in the order: SEARCH first, VSIM second.
    This PR sets up the syntax needed to support multiple subqueries in the future.

  3. Outcome: FT.HYBRID 2 SEARCH <search_query> VSIM <vector_query> is a valid syntax.

Which additional issues this PR fixes

  1. MOD-...
  2. #...

Main objects this PR modified

  1. ...

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

Note

Add parsing of an optional subqueries count after the index in FT.HYBRID (currently must be 2), adjusting errors and tests, and updating Python helper to emit the new syntax.

  • Parser (src/hybrid/parse_hybrid.c):
    • Add parseSubqueriesCount to handle optional <subqueries_count> after index in FT.HYBRID; require SEARCH after the count; enforce HYBRID_REQUEST_NUM_SUBQUERIES (2); preserve old format by accepting SEARCH when count is absent.
    • Integrate count parsing into parseHybridCommand and update error flows/messages accordingly.
  • C++ Tests (tests/cpptests/test_cpp_parse_hybrid.cpp):
    • Update expected error for missing SEARCH to reflect invalid/missing subqueries count.
    • Add comprehensive tests for subqueries count parsing (missing/invalid/non-2 values, missing SEARCH after count).
  • Python Test Utils (tests/pytests/utils/hybrid.py):
    • Update translate_hybrid_query to emit FT.HYBRID <index> 2 ....

Written by Cursor Bugbot for commit acbb7c4. This will update automatically on new commits. Configure here.

@codecov
Copy link

codecov bot commented Dec 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.05%. Comparing base (1bcbb7b) to head (acbb7c4).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7770      +/-   ##
==========================================
- Coverage   84.11%   84.05%   -0.07%     
==========================================
  Files         360      360              
  Lines       56242    56289      +47     
  Branches    15686    15717      +31     
==========================================
+ Hits        47310    47315       +5     
- Misses       8715     8758      +43     
+ Partials      217      216       -1     
Flag Coverage Δ
flow 84.87% <55.55%> (-0.07%) ⬇️
unit 52.09% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

to unsigned int subqueriesCount = 0;

Change "HYBRID supports only 2 subqueries" to "FT.HYBRID currently supports only two subqueries"
@Itzikvaknin Itzikvaknin requested a review from kei-nan December 22, 2025 11:54
@Itzikvaknin Itzikvaknin added this pull request to the merge queue Dec 22, 2025
Merged via the queue into master with commit fd91054 Dec 22, 2025
35 checks passed
@Itzikvaknin Itzikvaknin deleted the ivaknin_add_count_for_subqueries_in_ft_hybrid branch December 22, 2025 14:26
@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 8.4, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 8.4
git worktree add -d .worktree/backport-7770-to-8.4 origin/8.4
cd .worktree/backport-7770-to-8.4
git switch --create backport-7770-to-8.4
git cherry-pick -x fd91054d72b5c9d270ce89c40db891e92b78b78e

Itzikvaknin added a commit that referenced this pull request Dec 22, 2025
* Support subquery count (currently only 2) in FT.HYBRID, remain backward compatible

* Add comment on error massage and simplify if statement

* Newline EOF

* Change unsigned long long subqueries_count
to unsigned int subqueriesCount = 0;

Change "HYBRID supports only 2 subqueries" to "FT.HYBRID currently supports only two subqueries"

* Consolidate hybrid subqueries count logic and move it to a different name
github-merge-queue bot pushed a commit that referenced this pull request Dec 22, 2025
) (#7862)

* MOD-11858: Support subquery count in FT.HYBRID (#7770)

* Support subquery count (currently only 2) in FT.HYBRID, remain backward compatible

* Add comment on error massage and simplify if statement

* Newline EOF

* Change unsigned long long subqueries_count
to unsigned int subqueriesCount = 0;

Change "HYBRID supports only 2 subqueries" to "FT.HYBRID currently supports only two subqueries"

* Consolidate hybrid subqueries count logic and move it to a different name

* Updated error codes in parseSubqueriesCount to use the older concise version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants