Last column image_hash contains image hash of image files(varchar).
My goal is to create unique constraint on this column but it should follow one specific condition.
For example if image_hash 1 and image_hash 2 are the same - then similarity is 1
If they are completely different - similarity →0
For similarity I guess Hamming difference should suit well.
Condition is:
If similarity difference between image_hash 1 and image hash 2 is less then X (for example 0.1), then hashes considered the same and this would be uniqueness violation.
If similarity is bigger then X, then unique constraint is not violated.
I have tried :
SELECT image_hash, similarity(image_hash, '00041dffff101800') AS sml
FROM archives_imagemodel
WHERE id=431
But it is way to sensitive and I still don’t know how to convert it to unique constraint.
I am bad in Postgres, so that sorry if question is dumb or out of reality
Any ideas?
Thanks
