fix(search): initialize options in NewDropIndexBuilder to prevent panic (#4105)

Signed-off-by: Pragalva Sapkota <sapkotapragalva@gmail.com>
This commit is contained in:
Pragalva authored and GitHub committed 2026-10-19 14:30:36 +03:00
1 parent 9bb5c7c2c6
commit 5fcaf27e1a
2 files changed
+12 -2

No files matched your search

+2 -2
View File
@@ -562,10 +562,10 @@ type DropIndexBuilder struct {
// NewDropIndexBuilder creates a new DropIndexBuilder for FT.DROPINDEX commands.
// EXPERIMENTAL: this API is subject to change, use with caution.
func (c *Client) NewDropIndexBuilder(ctx context.Context, index string) *DropIndexBuilder {
return &DropIndexBuilder{c: c, ctx: ctx, index: index}
return &DropIndexBuilder{c: c, ctx: ctx, index: index, options: &FTDropIndexOptions{}}
}
// DeleteRuncs includes DD.
// DeleteDocs includes DD.
func (b *DropIndexBuilder) DeleteDocs() *DropIndexBuilder { b.options.DeleteDocs = true; return b }
// Run executes FT.DROPINDEX.
+10
View File
@@ -698,3 +698,13 @@ func TestParseFTHybridWarnings(t *testing.T) {
})
}
}
func TestDropIndexBuilderDeleteDocs(t *testing.T) {
client := NewClient(&Options{Addr: "localhost:6379"})
defer client.Close()
builder := client.NewDropIndexBuilder(context.Background(), "idx").DeleteDocs()
if builder.options == nil || !builder.options.DeleteDocs {
t.Fatal("expected DeleteDocs to be true")
}
}