You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds the shared query foundation needed for the remaining RedisVL Python parity work.
Adds BaseQuery for common FT.SEARCH query state and validation.
Adds BaseVectorQuery for vector-specific state, datatype normalization, and shared vector validation.
Moves VectorQuery, VectorRangeQuery, FilterQuery, CountQuery, and TextQuery onto the shared base classes without changing their constructor-facing APIs.
Adds chainable query helpers:
setFilter(...)
setReturnFields(...)
paging(...)
sortBy(...)
Wires query-level sortBy() through SearchIndex.search().
Stacking
This PR is stacked on top of #9 (feat/hybrid-search).
PR Notes\n\nReopened this as the next feature branch stacked on #9.\n\n- Base branch: \n- Head branch: \n- Scope: shared query foundation only\n\nThis should stay blocked on #9 landing first.
Thanks @nkanu17 — the BaseQuery / BaseVectorQuery design and the chainable helpers look great, and the test coverage is solid. A few items before merge:
1. Rebase onto current main
mergeable: CONFLICTING — feat/hybrid-search (#9), feat/aggregation-query-v2 (#28), and feat/redis-client-resp2-guard (#29) have all landed on main since this branch opened, so a rebase is needed.
2. Migrate HybridQuery and AggregationQuery onto BaseQuery in this PR
Both classes landed on main after this PR was opened, and neither extends BaseQuery:
src/query/hybrid.ts:245 — export class HybridQuery {
src/query/aggregation.ts:227 — export class AggregationQuery {
If they don't get migrated here, we ship main with split inheritance (5 query types on BaseQuery, 2 not) and a follow-up is guaranteed. I'd much rather they ride along with this PR than leave a known cleanup behind — please fold them in.
AggregationQuery is the easier of the two (FT.AGGREGATE doesn't share all of FT.SEARCH's state, so it may only inherit the filter/returnFields surface — feel free to push back if it doesn't fit cleanly). HybridQuery should be a natural fit since FT.HYBRID is closer to FT.SEARCH semantics.
3. Document sortBy precedence
SearchIndex.search() now sets SORTBY from query.sortFields[0], then overwrites it from options.sortBy if both are supplied. That's a reasonable choice (preserves the existing search() signature), but it needs to be documented on the SearchIndex.search JSDoc so callers know which wins. Worth a comment on the searchOptions.SORTBY assignment too.
4. Note the interface→class change in the PR body
Converting BaseQuery from an exported interface to an exported abstract class is technically a breaking change for anyone implementing the interface externally. At v0.1.0-beta this is fine, but please add a one-line note in the PR description so it ends up in the release notes when we cut the next version.
Re-review once #2 is in. Heads up that #31 (TextQuery stopwords) will likely land first — I've told that author they won't need to rebase against this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds the shared query foundation needed for the remaining RedisVL Python parity work.
BaseQueryfor common FT.SEARCH query state and validation.BaseVectorQueryfor vector-specific state, datatype normalization, and shared vector validation.VectorQuery,VectorRangeQuery,FilterQuery,CountQuery, andTextQueryonto the shared base classes without changing their constructor-facing APIs.setFilter(...)setReturnFields(...)paging(...)sortBy(...)sortBy()throughSearchIndex.search().Stacking
This PR is stacked on top of #9 (
feat/hybrid-search).Do not merge this PR before #9 lands.
TDD Notes
Tests were written first and failed before implementation:
tests/unit/query/base.test.tsBaseQuerycommon config, filter updates, return fields, skip-decode fields, paging, sorting, and validation.BaseVectorQueryvector state, datatype normalization, defensive copying, and validation.tests/unit/query/vector.test.tsVectorQueryinheritance fromBaseVectorQuery/BaseQuery.paging,setReturnFields, andsetFilterbehavior.tests/unit/indexes/search-index.test.tssortBy()reachesFT.SEARCHoptions.Implementation followed after the failing tests were in place.
Verification
npm run type-checknpm run test:unitnpm run format:check -- src/query/base.ts src/query/vector.ts src/query/range.ts src/query/filter-query.ts src/query/count.ts src/query/text.ts src/indexes/search-index.ts tests/unit/query/base.test.ts tests/unit/query/vector.test.ts tests/unit/indexes/search-index.test.tsnpm run buildREDISVL_SKIP_HYBRID=true npm test -- tests/integration