graphile-search 2.19.11 → 2.19.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/adapters/pgvector.js +4 -1
- package/codecs/vector-codec.js +16 -0
- package/esm/adapters/pgvector.js +4 -1
- package/esm/codecs/vector-codec.js +16 -0
- package/esm/plugin.js +7 -0
- package/package.json +2 -2
- package/plugin.js +7 -0
package/adapters/pgvector.js
CHANGED
|
@@ -49,9 +49,12 @@ function createPgvectorAdapter(options = {}) {
|
|
|
49
49
|
const chunksInfo = enableChunkQuerying ? (0, chunks_1.getChunksInfo)(codec) : undefined;
|
|
50
50
|
for (const [attributeName, attribute] of Object.entries(codec.attributes)) {
|
|
51
51
|
if (isVectorCodec(attribute.codec)) {
|
|
52
|
+
const dimensions = attribute.extensions?.vectorDimensions;
|
|
52
53
|
columns.push({
|
|
53
54
|
attributeName,
|
|
54
|
-
adapterData: chunksInfo
|
|
55
|
+
adapterData: chunksInfo || dimensions
|
|
56
|
+
? { ...(chunksInfo && { chunksInfo }), ...(dimensions && { dimensions }) }
|
|
57
|
+
: undefined,
|
|
55
58
|
});
|
|
56
59
|
}
|
|
57
60
|
}
|
package/codecs/vector-codec.js
CHANGED
|
@@ -60,6 +60,22 @@ exports.VectorCodecPlugin = {
|
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
62
|
},
|
|
63
|
+
/**
|
|
64
|
+
* Record a vector column's declared length (`vector(512)` → 512; pgvector's
|
|
65
|
+
* type modifier is the length itself) on the attribute, so a search that
|
|
66
|
+
* holds one query vector can tell which columns it can be compared with.
|
|
67
|
+
*/
|
|
68
|
+
async pgCodecs_attribute(_info, event) {
|
|
69
|
+
const { pgAttribute, attribute } = event;
|
|
70
|
+
if (attribute.codec?.name !== 'vector')
|
|
71
|
+
return;
|
|
72
|
+
const typmod = pgAttribute.atttypmod;
|
|
73
|
+
if (typmod == null || typmod < 1)
|
|
74
|
+
return;
|
|
75
|
+
if (!attribute.extensions)
|
|
76
|
+
attribute.extensions = {};
|
|
77
|
+
attribute.extensions.vectorDimensions = typmod;
|
|
78
|
+
},
|
|
63
79
|
},
|
|
64
80
|
},
|
|
65
81
|
schema: {
|
package/esm/adapters/pgvector.js
CHANGED
|
@@ -46,9 +46,12 @@ export function createPgvectorAdapter(options = {}) {
|
|
|
46
46
|
const chunksInfo = enableChunkQuerying ? getChunksInfo(codec) : undefined;
|
|
47
47
|
for (const [attributeName, attribute] of Object.entries(codec.attributes)) {
|
|
48
48
|
if (isVectorCodec(attribute.codec)) {
|
|
49
|
+
const dimensions = attribute.extensions?.vectorDimensions;
|
|
49
50
|
columns.push({
|
|
50
51
|
attributeName,
|
|
51
|
-
adapterData: chunksInfo
|
|
52
|
+
adapterData: chunksInfo || dimensions
|
|
53
|
+
? { ...(chunksInfo && { chunksInfo }), ...(dimensions && { dimensions }) }
|
|
54
|
+
: undefined,
|
|
52
55
|
});
|
|
53
56
|
}
|
|
54
57
|
}
|
|
@@ -54,6 +54,22 @@ export const VectorCodecPlugin = {
|
|
|
54
54
|
},
|
|
55
55
|
};
|
|
56
56
|
},
|
|
57
|
+
/**
|
|
58
|
+
* Record a vector column's declared length (`vector(512)` → 512; pgvector's
|
|
59
|
+
* type modifier is the length itself) on the attribute, so a search that
|
|
60
|
+
* holds one query vector can tell which columns it can be compared with.
|
|
61
|
+
*/
|
|
62
|
+
async pgCodecs_attribute(_info, event) {
|
|
63
|
+
const { pgAttribute, attribute } = event;
|
|
64
|
+
if (attribute.codec?.name !== 'vector')
|
|
65
|
+
return;
|
|
66
|
+
const typmod = pgAttribute.atttypmod;
|
|
67
|
+
if (typmod == null || typmod < 1)
|
|
68
|
+
return;
|
|
69
|
+
if (!attribute.extensions)
|
|
70
|
+
attribute.extensions = {};
|
|
71
|
+
attribute.extensions.vectorDimensions = typmod;
|
|
72
|
+
},
|
|
57
73
|
},
|
|
58
74
|
},
|
|
59
75
|
schema: {
|
package/esm/plugin.js
CHANGED
|
@@ -1004,6 +1004,13 @@ export function createUnifiedSearchPlugin(options) {
|
|
|
1004
1004
|
if (vector && vectorAdapterColumns.length > 0) {
|
|
1005
1005
|
for (const { adapter, columns } of vectorAdapterColumns) {
|
|
1006
1006
|
for (const column of columns) {
|
|
1007
|
+
// One query vector, embedded by the text model: a column of
|
|
1008
|
+
// another declared length (an image-embedding column beside
|
|
1009
|
+
// the text one) holds vectors it cannot be compared with —
|
|
1010
|
+
// pgvector raises on the operator — so it sits this search out.
|
|
1011
|
+
const declared = column.adapterData?.dimensions;
|
|
1012
|
+
if (declared && declared !== vector.length)
|
|
1013
|
+
continue;
|
|
1007
1014
|
const applyFor = (alias) => adapter.buildFilterApply(sql, alias, column, { vector, metric: 'COSINE' }, build);
|
|
1008
1015
|
const result = applyFor($condition.alias);
|
|
1009
1016
|
if (!result)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphile-search",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.12",
|
|
4
4
|
"description": "Unified PostGraphile v5 search plugin — abstracts tsvector, BM25, pg_trgm, and pgvector behind a single adapter-based architecture with composite searchScore",
|
|
5
5
|
"author": "Constructive <developers@constructive.io>",
|
|
6
6
|
"homepage": "https://github.com/constructive-io/constructive",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"hybrid-search",
|
|
66
66
|
"searchScore"
|
|
67
67
|
],
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "1dceb60e5be9ff31a9455f48a8a50399f0b9262c"
|
|
69
69
|
}
|
package/plugin.js
CHANGED
|
@@ -1007,6 +1007,13 @@ function createUnifiedSearchPlugin(options) {
|
|
|
1007
1007
|
if (vector && vectorAdapterColumns.length > 0) {
|
|
1008
1008
|
for (const { adapter, columns } of vectorAdapterColumns) {
|
|
1009
1009
|
for (const column of columns) {
|
|
1010
|
+
// One query vector, embedded by the text model: a column of
|
|
1011
|
+
// another declared length (an image-embedding column beside
|
|
1012
|
+
// the text one) holds vectors it cannot be compared with —
|
|
1013
|
+
// pgvector raises on the operator — so it sits this search out.
|
|
1014
|
+
const declared = column.adapterData?.dimensions;
|
|
1015
|
+
if (declared && declared !== vector.length)
|
|
1016
|
+
continue;
|
|
1010
1017
|
const applyFor = (alias) => adapter.buildFilterApply(sql, alias, column, { vector, metric: 'COSINE' }, build);
|
|
1011
1018
|
const result = applyFor($condition.alias);
|
|
1012
1019
|
if (!result)
|