RediSearch / JRediSearch

Java Client for RediSearch
https://redisearch.io
BSD 2-Clause "Simplified" License
141 stars 62 forks source link

dropindex method is mapped on FT.DROP Redis Command not on FT.DROPINDEX #182

Open alesAlten opened 2 years ago

alesAlten commented 2 years ago

The current implementation of "dropIndex" method, sends to Redis the FT.DROP command, not the FT.DROPINDEX. The difference is that FT.DROP command delete all documents in the index (tested with JSON document), while FT.DROPINDEX command (without DD parameter) does not delete all documents. At the moment is not possible programmatically to delete an index without deleting all documents indexed.

I attach a snippet of the Java code and the result of MONITOR command executed on a test environment. It shows as "rediSearchClient.dropIndex();" produce a "FT.DROP" "RootElementIDX" command. Automatically Redis delete the only document indexed in that moment (is JSON not an HASH) prior to drop the index: 1649349429.302994 [0 ?:0] "DEL" "RootElement:root-1"

To replicate: -----------Java code (createIndex is a private method that create the index, and redisSearchClientFactory is a factory method thaht creates an instance of the Client):

rediSearchClient = redisSearchClientFactory.apply("RootElementIDX"); rediSearchClient.getInfo(); rediSearchClient.dropIndex(); createIndex(rediSearchClient);

---------- Output of MONITOR command in a test environment

1649349429.300631 [0 172.18.0.1:44168] "FT.INFO" "RootElementIDX" 1649349429.302994 [0 ?:0] "DEL" "RootElement:root-1" 1649349429.303077 [0 172.18.0.1:44168] "FT.DROP" "RootElementIDX" 1649349429.306463 [0 172.18.0.1:44168] "FT.CREATE" "RootElementIDX" "ON" "JSON" "PREFIX" "1" "RootElement:" "SCHEMA" "$.id" "AS" "id" "TEXT" "$.score" "AS" "score" "NUMERIC" "SORTABLE"