redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.06k stars 108 forks source link

Potential issue with query-building in Redis OM #542

Open vladimirberns opened 11 months ago

vladimirberns commented 11 months ago

Hi there, I'm new to Redis. I'm using Redis OM and I'm experiencing an interesting issue. I created a model based off of the JSON response from a web service. It loads data correctly. However, when I call find and pass some criteria, it seems to swap the order of parts of the query randomly. For example, I can call the .find() code and 3 times out of 5 it won't return any results because it forms the query incorrectly. Here is an example from the profiler: Incorrect:

"FT.SEARCH" ":Models.vulnerability.Vulnerabilities:index" "@cve_cvssMetricV31_metrics_cvssData_baseSeverity:{critical}" "LIMIT" "0" "1000" Correct:

"FT.SEARCH" ":Models.vulnerability.Vulnerabilities:index" "@cve_metrics_cvssMetricV31_cvssData_baseSeverity:{critical}" "LIMIT" "0" "1000" notice how cvssMetricV31 and metrics are swapped. It's almost as if there's some instantiation issue happening when the models classes are being instantiated.

Update:

I stepped into the resolve_redisearch_query function and it seems like the Parents property is out of order. Is there a way to control the order in which the classes are instantiated? I'm currently doing Vulnerabilities.cve.metrics.cvssMetricV31.cvssData.baseSeverity == 'critical' as my query. I would have thought that would retain the order of the objects, but it seems to randomly move around the order of the Parents

slorello89 commented 2 months ago

Hi @vladimirberns - can you please share the model this was occuring with?