I am trying to delete a index using Jedis. I have the following…
public void deleteAll() {
// Optionally drop and recreate the index
try (Connection connection = jedis.getPool().getResource()) {
if (connection.isConnected()) {
connection.sendCommand(SearchProtocol.SearchCommand.DROPINDEX, "DROPINDEX", "spring-ai-example", "DD"); // Use your configured index name
} else {
logger.warn("Connection is not valid");
}
} catch (Exception e) {
// Index might not exist, that's okay
logger.warn("Failed to drop index", e);
}
}
When I run it everything runs fine without error but the index doesn’t get removed…
redis-cli FT._LIST
1) spring-ai-example
What am I missing how do I delete an index?
The cli version does work…
redis-cli FT.DROPINDEX spring-ai-example DD
2
Answers
This worked
You are sending
DROPINDEX
twice to the actual server command which should be just once.So just following should work:
On a side note: The
sendCommand
method inConnection
object does not read the server reply but theexecuteCommand
method does. So if you used executeCommand method, you would have got the command execution error in the server.