Skip to content

Add Query Builder for RediSearch commands #3436

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

Merged
merged 8 commits into from
Aug 4, 2025
Merged

Conversation

ofekshenawa
Copy link
Collaborator

A query API builder pattern for RediSearch commands in go-redis, providing a more intuitive and type safe way to construct complex search queries and operations.

Features Added

  • SearchBuilder : FT.SEARCH queries
  • AggregateBuilder: FT.AGGREGATE queries
  • ExplainBuilder: Query explanation with FT.EXPLAIN
  • SearchInfoBuilder: Index information retrieval
  • SpellCheckBuilder: Spell checking functionality
  • TagValsBuilder: Tag value enumeration
  • SynUpdateBuilder: Synonym management
  • CursorBuilder: Cursor-based result pagination
  • DictBuilder: Dictionary management
  • AliasBuilder: Index alias operations
  • DropIndexBuilder: Index deletion with options

Implementation Details

  • Builder pattern with method chaining
  • Lazy evaluation: commands execute only when Run() is called
  • Backward compatible: existing FT.* methods unchanged

* Add search module builders and tests

* Add tests
@ofekshenawa ofekshenawa marked this pull request as ready for review July 16, 2025 20:17
@ndyakov
Copy link
Member

ndyakov commented Jul 21, 2025

Hey @ofekshenawa, thank you for this contribution. @htemelski-redis and I will review it soon.

Copy link
Member

@ndyakov ndyakov left a comment

Choose a reason for hiding this comment

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

I do think it will make more sense to have New*Builder constructors, to not to the user that the return value will be a builder that they can use to build the command. Where there are Actions, we can either have one method per action or an Action method to set it. Letting you decide. I am maybe leaning towards the methods per actions, whatever you decide let's keep it consistent across all builders.

Copy link
Member

@ndyakov ndyakov left a comment

Choose a reason for hiding this comment

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

added couple of comments suggestion. Let's mark this as experimental and let the community provide feedback on the builders

Copy link
Member

@ndyakov ndyakov left a comment

Choose a reason for hiding this comment

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

Lets ship it and see what the community have to say 🚀

@ndyakov ndyakov added the feature label Aug 4, 2025
@ndyakov ndyakov merged commit f93bfa1 into redis:master Aug 4, 2025
20 checks passed
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.

2 participants