Module: Valkey::Commands::VectorSearchCommands
- Included in:
- Valkey::Commands
- Defined in:
- lib/valkey/commands/vector_search_commands.rb
Overview
This module contains commands related to RediSearch Vector Search.
RediSearch provides secondary indexing, full-text search, and vector similarity search capabilities on top of Redis/Valkey. These commands require the RediSearch module to be loaded.
Instance Method Summary collapse
-
#ft(subcommand, *args, **options) ⇒ Object
Convenience method for FT.* commands.
-
#ft_aggregate(index, query, *args) ⇒ Array
Run a search query with aggregations.
-
#ft_alias_add(alias_name, index) ⇒ String
Add an alias to an index.
-
#ft_alias_del(alias_name) ⇒ String
Delete an alias from an index.
-
#ft_alias_list ⇒ Array<String>
List all existing aliases.
-
#ft_alias_update(alias_name, index) ⇒ String
Update an alias to point to a different index.
-
#ft_create(index, *args) ⇒ String
Create a search index with the given schema.
-
#ft_drop_index(index, dd: false) ⇒ String
Drop an index and optionally delete all documents.
-
#ft_explain(index, query, *args) ⇒ String
Explain how a query is parsed and executed.
-
#ft_explain_cli(index, query, *args) ⇒ String
Explain how a query is parsed and executed (CLI-formatted output).
-
#ft_info(index) ⇒ Array
Get information about an index.
-
#ft_list ⇒ Array<String>
List all available indexes.
-
#ft_profile(index, query_type, *args) ⇒ Array
Profile a search or aggregation query.
-
#ft_search(index, query, *args) ⇒ Array
Search an index with a query.
Instance Method Details
#ft(subcommand, *args, **options) ⇒ Object
Convenience method for FT.* commands.
258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 258 def ft(subcommand, *args, **) subcommand = subcommand.to_s.downcase.gsub("-", "_") if args.empty? && .empty? send("ft_#{subcommand}") elsif .empty? send("ft_#{subcommand}", *args) else send("ft_#{subcommand}", *args, **) end end |
#ft_aggregate(index, query, *args) ⇒ Array
Run a search query with aggregations.
38 39 40 41 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 38 def ft_aggregate(index, query, *args) command_args = [index, query] + args send_command(RequestType::FT_AGGREGATE, command_args) end |
#ft_alias_add(alias_name, index) ⇒ String
Add an alias to an index.
54 55 56 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 54 def ft_alias_add(alias_name, index) send_command(RequestType::FT_ALIAS_ADD, [alias_name, index]) end |
#ft_alias_del(alias_name) ⇒ String
Delete an alias from an index.
68 69 70 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 68 def ft_alias_del(alias_name) send_command(RequestType::FT_ALIAS_DEL, [alias_name]) end |
#ft_alias_list ⇒ Array<String>
List all existing aliases.
81 82 83 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 81 def ft_alias_list send_command(RequestType::FT_ALIAS_LIST) end |
#ft_alias_update(alias_name, index) ⇒ String
Update an alias to point to a different index.
96 97 98 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 96 def ft_alias_update(alias_name, index) send_command(RequestType::FT_ALIAS_UPDATE, [alias_name, index]) end |
#ft_create(index, *args) ⇒ String
Create a search index with the given schema.
117 118 119 120 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 117 def ft_create(index, *args) command_args = [index] + args send_command(RequestType::FT_CREATE, command_args) end |
#ft_drop_index(index, dd: false) ⇒ String
Drop an index and optionally delete all documents.
137 138 139 140 141 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 137 def ft_drop_index(index, dd: false) args = [index] args << "DD" if dd send_command(RequestType::FT_DROP_INDEX, args) end |
#ft_explain(index, query, *args) ⇒ String
Explain how a query is parsed and executed.
155 156 157 158 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 155 def ft_explain(index, query, *args) command_args = [index, query] + args send_command(RequestType::FT_EXPLAIN, command_args) end |
#ft_explain_cli(index, query, *args) ⇒ String
Explain how a query is parsed and executed (CLI-formatted output).
172 173 174 175 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 172 def ft_explain_cli(index, query, *args) command_args = [index, query] + args send_command(RequestType::FT_EXPLAIN_CLI, command_args) end |
#ft_info(index) ⇒ Array
Get information about an index.
187 188 189 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 187 def ft_info(index) send_command(RequestType::FT_INFO, [index]) end |
#ft_list ⇒ Array<String>
List all available indexes.
22 23 24 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 22 def ft_list send_command(RequestType::FT_LIST) end |
#ft_profile(index, query_type, *args) ⇒ Array
Profile a search or aggregation query.
207 208 209 210 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 207 def ft_profile(index, query_type, *args) command_args = [index, query_type] + args send_command(RequestType::FT_PROFILE, command_args) end |
#ft_search(index, query, *args) ⇒ Array
Search an index with a query.
235 236 237 238 |
# File 'lib/valkey/commands/vector_search_commands.rb', line 235 def ft_search(index, query, *args) command_args = [index, query] + args send_command(RequestType::FT_SEARCH, command_args) end |