redis / redis-om-dotnet

Object mapping, and more, for Redis and .NET
MIT License
457 stars 76 forks source link

[Question] Adding new indexed properties to existing objects #333

Closed Artonus closed 1 year ago

Artonus commented 1 year ago

Hi there! I have a question regarding adding new Property to an already indexed object.

The problem I am facing is I am trying to query using the newly added property, but it doesn't find any objects. I suspect that it is due to the indexes not being up to date.

What I have found is the Index Migration command in the docs. https://github.com/redis/redis-om-dotnet/blob/main/docs/README.md#migrate Unfortunately, I cannot find it in the MigrateIndex function in the IRedisConnection.

Will I dropping the index and recreating it manually will solve the problem?

Redis.OM Version: 0.4.0

VagyokC4 commented 1 year ago

Will I dropping the index and recreating it manually will solve the problem?

It does yes. I too was looking for the migrate index, and had to just drop and re-create the index (which is less than ideal when moving to a prd env. as there is a time window when the results returned are in flux.)

Would be good to see the Migrate Index working.

slorello89 commented 1 year ago

Hi @Artonus - thanks for pointing that bit out - definitely doesn't belong in there - Migrate was something we considered adding a while ago (before Redis OM was released) but we elected not to because of the complexities involved, IIRC RediSearch has the ability to add but not delete fields with FT.ALTER - and without that crucial second bit it didn't make sense to implement. As @VagyokC4 points out you need to drop/create the index (again not ideal)

FYI @VagyokC4 - the FT.INFO command - see Connection.GetIndexInfo does return an Indexing property in it's result that does tell you whether the index is currently still in it's initial scan.

VagyokC4 commented 1 year ago

FYI @VagyokC4 - the FT.INFO command - see Connection.GetIndexInfo does return an Indexing property in it's result that does tell you whether the index is currently still in it's initial scan.

@slorello89 That's interesting. So the issue I've noticed is if the index is building, while we query, we may return NULL when a document actually exists. Thinking out loud, if we create a flag to help manage this so that when set, and a query comes back with no results, we can have it internally check if index is creating and if so, wait until complete and try to query again? Maybe even a Func WaitForIndexCreation exposed that would allow me to (in real-time) determine if we should wait for index creation and try the query again, or continue on with the empty results.