Sample set distance metrics for Postgres pgvector. Provides:
- Jaccard/Tanimoto distance for boolean vectors.
git clone https://github.com/CliffordWilmot/pgvector_set
cd pgvector_set
make CC=cc && make install
In order to use the functionality provided by this extension first install and enable the pgvector extension.
CREATE EXTENSION vector;
Enable the extension (do this once in each database where you want to use it).
CREATE EXTENSION vector_chem;
We define the operator <^>
for computing the Jaccard distance between two vectors of boolean values represented with 0.0 and 1.0.
SELECT '[1., 0., 1.]' <^> '[1., 0., 1.]';
-- ?column?
-- ----------
-- 0
-- (1 row)
The function jaccard_distance
is also defined and computes the same result as the <^>
operator.
SELECT jaccard_distance('[1., 0., 1.]', '[1., 0., 0.]');
-- jaccard_distance
-- -------------------
-- 0.5
-- (1 row)
Not at this time.
Not at this time.