Closed luisremis closed 2 years ago
This requires filtering of constraint after the knn is done. This is not a bug, it is an enhancement. I will update the wiki to reflect this is the expected behavior.
Is there a way to do this before knn is done? We are planning to have entities which contain properties on which we want to apply a constraint and then do a knn on the descriptors connected to them.
This enhancement here is different from what you need, it seems. This enhancement is about doing a knn and filter the closest neighbors by some constraints in the properties, everything within a single FindDescriptor.
What you are asking, it seems, is constraining the result of knn to only those descriptors linked with elements that result from some other find (findEntity, findImage) in the transaction. We do not support that at this time. Let me go over the implementation in the next couple of days and think how we can include that functionality.
To me this is fairly critical. There are many ways already of doing fast nearest neighbor searching on vectors, and filtering the results can be done in a few lines of python.
A good example of a successful approach here is elastic search, i.e. Boolean search followed by vectorspace search. The same could be achieved here by keeping a feature index and then having a way to fast cut down the candidate set using, say, binary flags.
When doing Descriptors knn and adding constraints, final result is not filtered correctly. A behavior for this case must be defined and added to the wiki.
Example case: