Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/server/acl/acl_family.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class AclFamily final {
{"SCRIPTING", SCRIPTING},
{"BLOOM", BLOOM},
{"FT_SEARCH", FT_SEARCH},
{"SEARCH", FT_SEARCH}, // Alias for FT_SEARCH
{"THROTTLE", THROTTLE},
{"JSON", JSON},
{"ALL", ALL}};
Expand Down
35 changes: 34 additions & 1 deletion src/server/search/search_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,38 @@ void SearchFamily::FtSynUpdate(CmdArgList args, const CommandContext& cmd_cntx)
cmd_cntx.rb->SendOk();
}

void SearchFamily::FtDebug(CmdArgList args, const CommandContext& cmd_cntx) {
// FT._DEBUG command stub for test compatibility
// This command is used by integration tests to control internal behavior
CmdArgParser parser{args};
auto* rb = static_cast<RedisReplyBuilder*>(cmd_cntx.rb);

if (args.empty() || parser.Check("HELP")) {
rb->SendSimpleString("FT._DEBUG - Debug command stub (not fully implemented)");
return;
}

// Handle CONTROLLED_VARIABLE subcommand used by tests
if (parser.Check("CONTROLLED_VARIABLE")) {
if (parser.Check("SET")) {
// Consume variable name and value - these are required by the command
parser.Next(); // variable name
parser.Next(); // variable value

if (auto err = parser.TakeError(); err) {
return rb->SendError(err.MakeReply());
}

// Just acknowledge the command
rb->SendOk();
return;
}
}

// For any other subcommand, just return OK
rb->SendOk();
}

#define HFUNC(x) SetHandler(&SearchFamily::x)

// Redis search is a module. Therefore we introduce dragonfly extension search
Expand Down Expand Up @@ -1874,7 +1906,8 @@ void SearchFamily::Register(CommandRegistry* registry) {
<< CI{"FT.TAGVALS", kReadOnlyMask, 3, 0, 0, acl::FT_SEARCH}.HFUNC(FtTagVals)
<< CI{"FT.SYNDUMP", kReadOnlyMask, 2, 0, 0, acl::FT_SEARCH}.HFUNC(FtSynDump)
<< CI{"FT.SYNUPDATE", CO::WRITE | CO::GLOBAL_TRANS, -4, 0, 0, acl::FT_SEARCH}.HFUNC(
FtSynUpdate);
FtSynUpdate)
<< CI{"FT._DEBUG", kReadOnlyMask, -1, 0, 0, acl::FT_SEARCH}.HFUNC(FtDebug);
}

} // namespace dfly
1 change: 1 addition & 0 deletions src/server/search/search_family.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class SearchFamily {
static void FtSynDump(CmdArgList args, const CommandContext& cmd_cntx);
static void FtSynUpdate(CmdArgList args, const CommandContext& cmd_cntx);
static void FtConfig(CmdArgList args, const CommandContext& cmd_cntx);
static void FtDebug(CmdArgList args, const CommandContext& cmd_cntx);

public:
static void Register(CommandRegistry* registry);
Expand Down
2 changes: 2 additions & 0 deletions src/server/server_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3246,11 +3246,13 @@ string ServerFamily::FormatInfoMetrics(const Metrics& m, std::string_view sectio
"errors]");
}

#ifdef WITH_SEARCH
if (should_enter("SEARCH", true)) {
append("search_memory", m.search_stats.used_memory);
append("search_num_indices", m.search_stats.num_indices);
append("search_num_entries", m.search_stats.num_entries);
}
#endif

if (should_enter("ERRORSTATS", true)) {
for (const auto& k_v : m.facade_stats.reply_stats.err_count) {
Expand Down
Loading