graphile-search 1.5.7 → 1.5.9
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/esm/plugin.js +8 -8
- package/esm/preset.d.ts +2 -2
- package/esm/preset.js +2 -2
- package/esm/types.d.ts +5 -5
- package/package.json +5 -5
- package/plugin.js +8 -8
- package/preset.d.ts +2 -2
- package/preset.js +2 -2
- package/types.d.ts +5 -5
package/esm/plugin.js
CHANGED
|
@@ -101,7 +101,7 @@ function applyRecencyBoost(normalizedScore, recencyValue, decay) {
|
|
|
101
101
|
* Creates the unified search plugin with the given options.
|
|
102
102
|
*/
|
|
103
103
|
export function createUnifiedSearchPlugin(options) {
|
|
104
|
-
const { adapters, enableSearchScore = true,
|
|
104
|
+
const { adapters, enableSearchScore = true, enableUnifiedSearch = true } = options;
|
|
105
105
|
// Per-codec cache of discovered columns, keyed by codec name
|
|
106
106
|
const codecCache = new Map();
|
|
107
107
|
// Bridge between orderBy enum apply and filter apply.
|
|
@@ -349,7 +349,7 @@ export function createUnifiedSearchPlugin(options) {
|
|
|
349
349
|
});
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
|
-
// Read per-table @searchConfig smart tag (written by
|
|
352
|
+
// Read per-table @searchConfig smart tag (written by SearchUnified/SearchFullText/SearchBm25)
|
|
353
353
|
// Per-table config overrides global searchScoreWeights
|
|
354
354
|
const tableSearchConfig = getSearchConfig(codec);
|
|
355
355
|
// Resolve effective weights: per-table > global > equal (undefined)
|
|
@@ -620,21 +620,21 @@ export function createUnifiedSearchPlugin(options) {
|
|
|
620
620
|
}, `UnifiedSearchPlugin adding ${adapter.name} filter field '${fieldName}' for '${column.attributeName}' on '${codec.name}'`);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
|
-
// ──
|
|
624
|
-
// Adds a single `
|
|
623
|
+
// ── unifiedSearch composite filter ──
|
|
624
|
+
// Adds a single `unifiedSearch: String` field that fans out the same
|
|
625
625
|
// text query to all adapters where supportsTextSearch is true.
|
|
626
626
|
// WHERE clauses are combined with OR (match ANY algorithm).
|
|
627
|
-
if (
|
|
627
|
+
if (enableUnifiedSearch) {
|
|
628
628
|
// Collect text-compatible adapters and their columns for this codec
|
|
629
629
|
const textAdapterColumns = adapterColumns.filter((ac) => ac.adapter.supportsTextSearch && ac.adapter.buildTextSearchInput);
|
|
630
630
|
if (textAdapterColumns.length > 0) {
|
|
631
|
-
const fieldName = '
|
|
631
|
+
const fieldName = 'unifiedSearch';
|
|
632
632
|
newFields = build.extend(newFields, {
|
|
633
633
|
[fieldName]: fieldWithHooks({
|
|
634
634
|
fieldName,
|
|
635
635
|
isPgConnectionFilterField: true,
|
|
636
636
|
}, {
|
|
637
|
-
description: build.wrapDescription('Composite
|
|
637
|
+
description: build.wrapDescription('Composite unified search. Provide a search string and it will be dispatched ' +
|
|
638
638
|
'to all text-compatible search algorithms (tsvector, BM25, pg_trgm) simultaneously. ' +
|
|
639
639
|
'Rows matching ANY algorithm are returned. All matching score fields are populated.', 'field'),
|
|
640
640
|
type: build.graphql.GraphQLString,
|
|
@@ -695,7 +695,7 @@ export function createUnifiedSearchPlugin(options) {
|
|
|
695
695
|
}
|
|
696
696
|
},
|
|
697
697
|
}),
|
|
698
|
-
}, `UnifiedSearchPlugin adding
|
|
698
|
+
}, `UnifiedSearchPlugin adding unifiedSearch composite filter on '${codec.name}'`);
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
701
|
return newFields;
|
package/esm/preset.d.ts
CHANGED
|
@@ -51,10 +51,10 @@ export interface UnifiedSearchPresetOptions {
|
|
|
51
51
|
*/
|
|
52
52
|
enableSearchScore?: boolean;
|
|
53
53
|
/**
|
|
54
|
-
* Whether to expose the composite `
|
|
54
|
+
* Whether to expose the composite `unifiedSearch` filter field.
|
|
55
55
|
* @default true
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
enableUnifiedSearch?: boolean;
|
|
58
58
|
/**
|
|
59
59
|
* Custom weights for the composite searchScore.
|
|
60
60
|
* Keys are adapter names ('tsv', 'bm25', 'trgm', 'vector'),
|
package/esm/preset.js
CHANGED
|
@@ -29,7 +29,7 @@ import { createMatchesOperatorFactory, createTrgmOperatorFactories } from './cod
|
|
|
29
29
|
* Creates a preset that includes the unified search plugin with all enabled adapters.
|
|
30
30
|
*/
|
|
31
31
|
export function UnifiedSearchPreset(options = {}) {
|
|
32
|
-
const { tsvector = true, bm25 = true, trgm = true, pgvector = true, enableSearchScore = true,
|
|
32
|
+
const { tsvector = true, bm25 = true, trgm = true, pgvector = true, enableSearchScore = true, enableUnifiedSearch = true, searchScoreWeights, fullTextScalarName = 'FullText', tsConfig = 'english', } = options;
|
|
33
33
|
const adapters = [];
|
|
34
34
|
if (tsvector) {
|
|
35
35
|
const opts = typeof tsvector === 'object' ? tsvector : {};
|
|
@@ -50,7 +50,7 @@ export function UnifiedSearchPreset(options = {}) {
|
|
|
50
50
|
const pluginOptions = {
|
|
51
51
|
adapters,
|
|
52
52
|
enableSearchScore,
|
|
53
|
-
|
|
53
|
+
enableUnifiedSearch,
|
|
54
54
|
searchScoreWeights,
|
|
55
55
|
};
|
|
56
56
|
// Collect codec plugins based on which adapters are enabled
|
package/esm/types.d.ts
CHANGED
|
@@ -100,7 +100,7 @@ export interface SearchAdapter {
|
|
|
100
100
|
/**
|
|
101
101
|
* Whether this adapter supports plain text search queries.
|
|
102
102
|
* If true, the adapter's columns will be included in the automatic
|
|
103
|
-
* `
|
|
103
|
+
* `unifiedSearch` composite filter that fans out the same text query
|
|
104
104
|
* to all text-compatible adapters simultaneously.
|
|
105
105
|
*
|
|
106
106
|
* Adapters that require non-text input (e.g. pgvector needs a vector array)
|
|
@@ -110,7 +110,7 @@ export interface SearchAdapter {
|
|
|
110
110
|
*/
|
|
111
111
|
supportsTextSearch?: boolean;
|
|
112
112
|
/**
|
|
113
|
-
* Build the filter value for a text search query dispatched by
|
|
113
|
+
* Build the filter value for a text search query dispatched by unifiedSearch.
|
|
114
114
|
* Only called when supportsTextSearch is true.
|
|
115
115
|
* Converts a plain text string into the adapter-specific filter input format.
|
|
116
116
|
*
|
|
@@ -179,14 +179,14 @@ export interface UnifiedSearchOptions {
|
|
|
179
179
|
*/
|
|
180
180
|
enableSearchScore?: boolean;
|
|
181
181
|
/**
|
|
182
|
-
* Whether to expose the `
|
|
182
|
+
* Whether to expose the `unifiedSearch` composite filter field.
|
|
183
183
|
* When enabled, every table with at least one text-compatible adapter gets a
|
|
184
|
-
* `
|
|
184
|
+
* `unifiedSearch: String` field on its filter type. Providing a value fans
|
|
185
185
|
* out the same text query to all adapters where `supportsTextSearch: true`,
|
|
186
186
|
* combining their WHERE clauses with OR (match any algorithm).
|
|
187
187
|
* @default true
|
|
188
188
|
*/
|
|
189
|
-
|
|
189
|
+
enableUnifiedSearch?: boolean;
|
|
190
190
|
/**
|
|
191
191
|
* Custom weights for the composite searchScore. Keys are adapter names,
|
|
192
192
|
* values are relative weights (will be normalized to sum to 1.0).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphile-search",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.9",
|
|
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",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^22.19.11",
|
|
33
33
|
"@types/pg": "^8.18.0",
|
|
34
|
-
"graphile-connection-filter": "^1.3.
|
|
35
|
-
"graphile-test": "^4.7.
|
|
34
|
+
"graphile-connection-filter": "^1.3.7",
|
|
35
|
+
"graphile-test": "^4.7.7",
|
|
36
36
|
"makage": "^0.3.0",
|
|
37
37
|
"pg": "^8.20.0",
|
|
38
|
-
"pgsql-test": "^4.7.
|
|
38
|
+
"pgsql-test": "^4.7.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@dataplan/pg": "1.0.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"hybrid-search",
|
|
63
63
|
"searchScore"
|
|
64
64
|
],
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "b0b6f07955974ab896a058a69196eaf4bb445feb"
|
|
66
66
|
}
|
package/plugin.js
CHANGED
|
@@ -104,7 +104,7 @@ function applyRecencyBoost(normalizedScore, recencyValue, decay) {
|
|
|
104
104
|
* Creates the unified search plugin with the given options.
|
|
105
105
|
*/
|
|
106
106
|
function createUnifiedSearchPlugin(options) {
|
|
107
|
-
const { adapters, enableSearchScore = true,
|
|
107
|
+
const { adapters, enableSearchScore = true, enableUnifiedSearch = true } = options;
|
|
108
108
|
// Per-codec cache of discovered columns, keyed by codec name
|
|
109
109
|
const codecCache = new Map();
|
|
110
110
|
// Bridge between orderBy enum apply and filter apply.
|
|
@@ -352,7 +352,7 @@ function createUnifiedSearchPlugin(options) {
|
|
|
352
352
|
});
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
|
-
// Read per-table @searchConfig smart tag (written by
|
|
355
|
+
// Read per-table @searchConfig smart tag (written by SearchUnified/SearchFullText/SearchBm25)
|
|
356
356
|
// Per-table config overrides global searchScoreWeights
|
|
357
357
|
const tableSearchConfig = getSearchConfig(codec);
|
|
358
358
|
// Resolve effective weights: per-table > global > equal (undefined)
|
|
@@ -623,21 +623,21 @@ function createUnifiedSearchPlugin(options) {
|
|
|
623
623
|
}, `UnifiedSearchPlugin adding ${adapter.name} filter field '${fieldName}' for '${column.attributeName}' on '${codec.name}'`);
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
|
-
// ──
|
|
627
|
-
// Adds a single `
|
|
626
|
+
// ── unifiedSearch composite filter ──
|
|
627
|
+
// Adds a single `unifiedSearch: String` field that fans out the same
|
|
628
628
|
// text query to all adapters where supportsTextSearch is true.
|
|
629
629
|
// WHERE clauses are combined with OR (match ANY algorithm).
|
|
630
|
-
if (
|
|
630
|
+
if (enableUnifiedSearch) {
|
|
631
631
|
// Collect text-compatible adapters and their columns for this codec
|
|
632
632
|
const textAdapterColumns = adapterColumns.filter((ac) => ac.adapter.supportsTextSearch && ac.adapter.buildTextSearchInput);
|
|
633
633
|
if (textAdapterColumns.length > 0) {
|
|
634
|
-
const fieldName = '
|
|
634
|
+
const fieldName = 'unifiedSearch';
|
|
635
635
|
newFields = build.extend(newFields, {
|
|
636
636
|
[fieldName]: fieldWithHooks({
|
|
637
637
|
fieldName,
|
|
638
638
|
isPgConnectionFilterField: true,
|
|
639
639
|
}, {
|
|
640
|
-
description: build.wrapDescription('Composite
|
|
640
|
+
description: build.wrapDescription('Composite unified search. Provide a search string and it will be dispatched ' +
|
|
641
641
|
'to all text-compatible search algorithms (tsvector, BM25, pg_trgm) simultaneously. ' +
|
|
642
642
|
'Rows matching ANY algorithm are returned. All matching score fields are populated.', 'field'),
|
|
643
643
|
type: build.graphql.GraphQLString,
|
|
@@ -698,7 +698,7 @@ function createUnifiedSearchPlugin(options) {
|
|
|
698
698
|
}
|
|
699
699
|
},
|
|
700
700
|
}),
|
|
701
|
-
}, `UnifiedSearchPlugin adding
|
|
701
|
+
}, `UnifiedSearchPlugin adding unifiedSearch composite filter on '${codec.name}'`);
|
|
702
702
|
}
|
|
703
703
|
}
|
|
704
704
|
return newFields;
|
package/preset.d.ts
CHANGED
|
@@ -51,10 +51,10 @@ export interface UnifiedSearchPresetOptions {
|
|
|
51
51
|
*/
|
|
52
52
|
enableSearchScore?: boolean;
|
|
53
53
|
/**
|
|
54
|
-
* Whether to expose the composite `
|
|
54
|
+
* Whether to expose the composite `unifiedSearch` filter field.
|
|
55
55
|
* @default true
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
enableUnifiedSearch?: boolean;
|
|
58
58
|
/**
|
|
59
59
|
* Custom weights for the composite searchScore.
|
|
60
60
|
* Keys are adapter names ('tsv', 'bm25', 'trgm', 'vector'),
|
package/preset.js
CHANGED
|
@@ -32,7 +32,7 @@ const operator_factories_1 = require("./codecs/operator-factories");
|
|
|
32
32
|
* Creates a preset that includes the unified search plugin with all enabled adapters.
|
|
33
33
|
*/
|
|
34
34
|
function UnifiedSearchPreset(options = {}) {
|
|
35
|
-
const { tsvector = true, bm25 = true, trgm = true, pgvector = true, enableSearchScore = true,
|
|
35
|
+
const { tsvector = true, bm25 = true, trgm = true, pgvector = true, enableSearchScore = true, enableUnifiedSearch = true, searchScoreWeights, fullTextScalarName = 'FullText', tsConfig = 'english', } = options;
|
|
36
36
|
const adapters = [];
|
|
37
37
|
if (tsvector) {
|
|
38
38
|
const opts = typeof tsvector === 'object' ? tsvector : {};
|
|
@@ -53,7 +53,7 @@ function UnifiedSearchPreset(options = {}) {
|
|
|
53
53
|
const pluginOptions = {
|
|
54
54
|
adapters,
|
|
55
55
|
enableSearchScore,
|
|
56
|
-
|
|
56
|
+
enableUnifiedSearch,
|
|
57
57
|
searchScoreWeights,
|
|
58
58
|
};
|
|
59
59
|
// Collect codec plugins based on which adapters are enabled
|
package/types.d.ts
CHANGED
|
@@ -100,7 +100,7 @@ export interface SearchAdapter {
|
|
|
100
100
|
/**
|
|
101
101
|
* Whether this adapter supports plain text search queries.
|
|
102
102
|
* If true, the adapter's columns will be included in the automatic
|
|
103
|
-
* `
|
|
103
|
+
* `unifiedSearch` composite filter that fans out the same text query
|
|
104
104
|
* to all text-compatible adapters simultaneously.
|
|
105
105
|
*
|
|
106
106
|
* Adapters that require non-text input (e.g. pgvector needs a vector array)
|
|
@@ -110,7 +110,7 @@ export interface SearchAdapter {
|
|
|
110
110
|
*/
|
|
111
111
|
supportsTextSearch?: boolean;
|
|
112
112
|
/**
|
|
113
|
-
* Build the filter value for a text search query dispatched by
|
|
113
|
+
* Build the filter value for a text search query dispatched by unifiedSearch.
|
|
114
114
|
* Only called when supportsTextSearch is true.
|
|
115
115
|
* Converts a plain text string into the adapter-specific filter input format.
|
|
116
116
|
*
|
|
@@ -179,14 +179,14 @@ export interface UnifiedSearchOptions {
|
|
|
179
179
|
*/
|
|
180
180
|
enableSearchScore?: boolean;
|
|
181
181
|
/**
|
|
182
|
-
* Whether to expose the `
|
|
182
|
+
* Whether to expose the `unifiedSearch` composite filter field.
|
|
183
183
|
* When enabled, every table with at least one text-compatible adapter gets a
|
|
184
|
-
* `
|
|
184
|
+
* `unifiedSearch: String` field on its filter type. Providing a value fans
|
|
185
185
|
* out the same text query to all adapters where `supportsTextSearch: true`,
|
|
186
186
|
* combining their WHERE clauses with OR (match any algorithm).
|
|
187
187
|
* @default true
|
|
188
188
|
*/
|
|
189
|
-
|
|
189
|
+
enableUnifiedSearch?: boolean;
|
|
190
190
|
/**
|
|
191
191
|
* Custom weights for the composite searchScore. Keys are adapter names,
|
|
192
192
|
* values are relative weights (will be normalized to sum to 1.0).
|