StackExchange / NRediSearch

Other
31 stars 9 forks source link

NRedisearch : DropIndex deletes documents in all Indexes #13

Closed Sangeetha-Murugesan closed 2 years ago

Sangeetha-Murugesan commented 3 years ago

Hi ,

I m using Redisearch(Version: NRedisearch 2.2.62) with two Indexes say UserInfo and ContactInfo. When I try to drop the index ContactInfo, the documents updated in UserInfo also gets cleared. I m using the following code to drop the index,
  var _client = new Client("ContactInfo", db);
  bool res=_client.DropIndex();
slorello89 commented 3 years ago

This is actually the intended behavior as NRediSearch uses the FT.DROP command when you call DropIndex - You can just drop the index without dropping the records indexed by using the FT.DROPINDEX command. You can call this explicitly through the RedisDatabase object you used to initialize the Client:

db.Execute("FT.DROPINDEX", "ContactInfo");
Sangeetha-Murugesan commented 2 years ago

Actually, I missed out adding prefix while creating index which results in document deletion across all indexes. After adding prefix to every index, only the specific index is get deleted on ft.drop command