@stacksjs/search-engine 0.70.37 → 0.70.43
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.
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configure Algolia client
|
|
3
|
+
*/
|
|
4
|
+
export declare function configure(options: AlgoliaConfig): void;
|
|
5
|
+
/**
|
|
6
|
+
* Search an index
|
|
7
|
+
*/
|
|
8
|
+
export declare function search(indexName: string, params?: AlgoliaSearchParams): Promise<AlgoliaSearchResponse>;
|
|
9
|
+
/**
|
|
10
|
+
* Multi-index search
|
|
11
|
+
*/
|
|
12
|
+
export declare function multiSearch(queries: Array<{ indexName: string, params?: AlgoliaSearchParams }>): Promise<{ results: AlgoliaSearchResponse[] }>;
|
|
13
|
+
/**
|
|
14
|
+
* Add or update a single object
|
|
15
|
+
*/
|
|
16
|
+
export declare function saveObject(indexName: string, object: Record<string, any>, objectID?: string): Promise<AlgoliaTask>;
|
|
17
|
+
/**
|
|
18
|
+
* Add or update multiple objects
|
|
19
|
+
*/
|
|
20
|
+
export declare function saveObjects(indexName: string, objects: Array<Record<string, any>>): Promise<AlgoliaTask>;
|
|
21
|
+
/**
|
|
22
|
+
* Partially update an object
|
|
23
|
+
*/
|
|
24
|
+
export declare function partialUpdateObject(indexName: string, objectID: string, attributes: Record<string, any>, createIfNotExists?: boolean): Promise<AlgoliaTask>;
|
|
25
|
+
/**
|
|
26
|
+
* Delete an object
|
|
27
|
+
*/
|
|
28
|
+
export declare function deleteObject(indexName: string, objectID: string): Promise<AlgoliaTask>;
|
|
29
|
+
/**
|
|
30
|
+
* Delete multiple objects
|
|
31
|
+
*/
|
|
32
|
+
export declare function deleteObjects(indexName: string, objectIDs: string[]): Promise<AlgoliaTask>;
|
|
33
|
+
/**
|
|
34
|
+
* Delete objects matching a filter
|
|
35
|
+
*/
|
|
36
|
+
export declare function deleteBy(indexName: string, filters: string): Promise<AlgoliaTask>;
|
|
37
|
+
/**
|
|
38
|
+
* Get an object by ID
|
|
39
|
+
*/
|
|
40
|
+
export declare function getObject(indexName: string, objectID: string, attributesToRetrieve?: string[]): Promise<AlgoliaHit>;
|
|
41
|
+
/**
|
|
42
|
+
* Get multiple objects by IDs
|
|
43
|
+
*/
|
|
44
|
+
export declare function getObjects(indexName: string, objectIDs: string[], attributesToRetrieve?: string[]): Promise<{ results: AlgoliaHit[] }>;
|
|
45
|
+
/**
|
|
46
|
+
* Clear all objects from an index
|
|
47
|
+
*/
|
|
48
|
+
export declare function clearObjects(indexName: string): Promise<AlgoliaTask>;
|
|
49
|
+
/**
|
|
50
|
+
* Get index settings
|
|
51
|
+
*/
|
|
52
|
+
export declare function getSettings(indexName: string): Promise<AlgoliaIndexSettings>;
|
|
53
|
+
/**
|
|
54
|
+
* Update index settings
|
|
55
|
+
*/
|
|
56
|
+
export declare function setSettings(indexName: string, settings: AlgoliaIndexSettings, forwardToReplicas?: boolean): Promise<AlgoliaTask>;
|
|
57
|
+
/**
|
|
58
|
+
* List all indices
|
|
59
|
+
*/
|
|
60
|
+
export declare function listIndices(): Promise<{
|
|
61
|
+
items: Array<{
|
|
62
|
+
name: string
|
|
63
|
+
createdAt: string
|
|
64
|
+
updatedAt: string
|
|
65
|
+
entries: number
|
|
66
|
+
dataSize: number
|
|
67
|
+
fileSize: number
|
|
68
|
+
lastBuildTimeS: number
|
|
69
|
+
numberOfPendingTasks: number
|
|
70
|
+
pendingTask: boolean
|
|
71
|
+
primary?: string
|
|
72
|
+
replicas?: string[]
|
|
73
|
+
}>
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Copy an index
|
|
77
|
+
*/
|
|
78
|
+
export declare function copyIndex(srcIndexName: string, dstIndexName: string, scope?: Array<'settings' | 'synonyms' | 'rules'>): Promise<AlgoliaTask>;
|
|
79
|
+
/**
|
|
80
|
+
* Move an index
|
|
81
|
+
*/
|
|
82
|
+
export declare function moveIndex(srcIndexName: string, dstIndexName: string): Promise<AlgoliaTask>;
|
|
83
|
+
/**
|
|
84
|
+
* Delete an index
|
|
85
|
+
*/
|
|
86
|
+
export declare function deleteIndex(indexName: string): Promise<AlgoliaTask>;
|
|
87
|
+
/**
|
|
88
|
+
* Check if an index exists
|
|
89
|
+
*/
|
|
90
|
+
export declare function indexExists(indexName: string): Promise<boolean>;
|
|
91
|
+
/**
|
|
92
|
+
* Wait for a task to complete
|
|
93
|
+
*/
|
|
94
|
+
export declare function waitTask(indexName: string, taskID: number, timeoutMs?: number, intervalMs?: number): Promise<{ status: 'published' | 'notPublished' }>;
|
|
95
|
+
/**
|
|
96
|
+
* Add a synonym
|
|
97
|
+
*/
|
|
98
|
+
export declare function saveSynonym(indexName: string, synonym: {
|
|
99
|
+
objectID: string
|
|
100
|
+
type: 'synonym' | 'oneWaySynonym' | 'altCorrection1' | 'altCorrection2' | 'placeholder'
|
|
101
|
+
synonyms?: string[]
|
|
102
|
+
input?: string
|
|
103
|
+
word?: string
|
|
104
|
+
corrections?: string[]
|
|
105
|
+
placeholder?: string
|
|
106
|
+
replacements?: string[]
|
|
107
|
+
}, forwardToReplicas?: boolean): Promise<AlgoliaTask>;
|
|
108
|
+
/**
|
|
109
|
+
* Search synonyms
|
|
110
|
+
*/
|
|
111
|
+
export declare function searchSynonyms(indexName: string, query?: string, type?: string, page?: number, hitsPerPage?: number): Promise<{ hits: any[], nbHits: number }>;
|
|
112
|
+
/**
|
|
113
|
+
* Clear all synonyms
|
|
114
|
+
*/
|
|
115
|
+
export declare function clearSynonyms(indexName: string, forwardToReplicas?: boolean): Promise<AlgoliaTask>;
|
|
116
|
+
/**
|
|
117
|
+
* Add a rule
|
|
118
|
+
*/
|
|
119
|
+
export declare function saveRule(indexName: string, rule: {
|
|
120
|
+
objectID: string
|
|
121
|
+
conditions?: Array<{
|
|
122
|
+
pattern?: string
|
|
123
|
+
anchoring?: 'is' | 'startsWith' | 'endsWith' | 'contains'
|
|
124
|
+
context?: string
|
|
125
|
+
}>
|
|
126
|
+
consequence: {
|
|
127
|
+
params?: Record<string, any>
|
|
128
|
+
promote?: Array<{ objectID: string, position: number }>
|
|
129
|
+
hide?: Array<{ objectID: string }>
|
|
130
|
+
userData?: Record<string, any>
|
|
131
|
+
}
|
|
132
|
+
description?: string
|
|
133
|
+
enabled?: boolean
|
|
134
|
+
validity?: Array<{ from: number, until: number }>
|
|
135
|
+
}, forwardToReplicas?: boolean): Promise<AlgoliaTask>;
|
|
136
|
+
/**
|
|
137
|
+
* Search rules
|
|
138
|
+
*/
|
|
139
|
+
export declare function searchRules(indexName: string, query?: string, anchoring?: string, context?: string, page?: number, hitsPerPage?: number): Promise<{ hits: any[], nbHits: number }>;
|
|
140
|
+
/**
|
|
141
|
+
* Clear all rules
|
|
142
|
+
*/
|
|
143
|
+
export declare function clearRules(indexName: string, forwardToReplicas?: boolean): Promise<AlgoliaTask>;
|
|
144
|
+
/**
|
|
145
|
+
* Browse all records in an index
|
|
146
|
+
*/
|
|
147
|
+
export declare function browse(indexName: string, params?: AlgoliaSearchParams): AsyncGenerator<AlgoliaHit>;
|
|
148
|
+
export declare const algolia: {
|
|
149
|
+
|
|
150
|
+
};
|
|
151
|
+
export declare interface AlgoliaConfig {
|
|
152
|
+
appId: string
|
|
153
|
+
apiKey: string
|
|
154
|
+
searchOnlyApiKey?: string
|
|
155
|
+
}
|
|
156
|
+
export declare interface AlgoliaSearchParams {
|
|
157
|
+
query?: string
|
|
158
|
+
page?: number
|
|
159
|
+
hitsPerPage?: number
|
|
160
|
+
filters?: string
|
|
161
|
+
facets?: string[]
|
|
162
|
+
attributesToRetrieve?: string[]
|
|
163
|
+
attributesToHighlight?: string[]
|
|
164
|
+
attributesToSnippet?: string[]
|
|
165
|
+
sortBy?: string
|
|
166
|
+
}
|
|
167
|
+
export declare interface AlgoliaHit {
|
|
168
|
+
objectID: string
|
|
169
|
+
[key: string]: any
|
|
170
|
+
}
|
|
171
|
+
export declare interface AlgoliaSearchResponse {
|
|
172
|
+
hits: AlgoliaHit[]
|
|
173
|
+
nbHits: number
|
|
174
|
+
page: number
|
|
175
|
+
nbPages: number
|
|
176
|
+
hitsPerPage: number
|
|
177
|
+
processingTimeMS: number
|
|
178
|
+
query: string
|
|
179
|
+
params: string
|
|
180
|
+
facets?: Record<string, Record<string, number>>
|
|
181
|
+
}
|
|
182
|
+
export declare interface AlgoliaIndexSettings {
|
|
183
|
+
searchableAttributes?: string[]
|
|
184
|
+
attributesForFaceting?: string[]
|
|
185
|
+
unretrievableAttributes?: string[]
|
|
186
|
+
attributesToRetrieve?: string[]
|
|
187
|
+
ranking?: string[]
|
|
188
|
+
customRanking?: string[]
|
|
189
|
+
replicas?: string[]
|
|
190
|
+
maxValuesPerFacet?: number
|
|
191
|
+
sortFacetValuesBy?: 'count' | 'alpha'
|
|
192
|
+
attributesToHighlight?: string[]
|
|
193
|
+
attributesToSnippet?: string[]
|
|
194
|
+
highlightPreTag?: string
|
|
195
|
+
highlightPostTag?: string
|
|
196
|
+
snippetEllipsisText?: string
|
|
197
|
+
restrictHighlightAndSnippetArrays?: boolean
|
|
198
|
+
minWordSizefor1Typo?: number
|
|
199
|
+
minWordSizefor2Typos?: number
|
|
200
|
+
typoTolerance?: boolean | 'min' | 'strict'
|
|
201
|
+
allowTyposOnNumericTokens?: boolean
|
|
202
|
+
disableTypoToleranceOnAttributes?: string[]
|
|
203
|
+
ignorePlurals?: boolean | string[]
|
|
204
|
+
removeStopWords?: boolean | string[]
|
|
205
|
+
separatorsToIndex?: string
|
|
206
|
+
queryType?: 'prefixLast' | 'prefixAll' | 'prefixNone'
|
|
207
|
+
removeWordsIfNoResults?: 'none' | 'lastWords' | 'firstWords' | 'allOptional'
|
|
208
|
+
advancedSyntax?: boolean
|
|
209
|
+
optionalWords?: string[]
|
|
210
|
+
disablePrefixOnAttributes?: string[]
|
|
211
|
+
disableExactOnAttributes?: string[]
|
|
212
|
+
exactOnSingleWordQuery?: 'attribute' | 'none' | 'word'
|
|
213
|
+
alternativesAsExact?: Array<'ignorePlurals' | 'singleWordSynonym' | 'multiWordsSynonym'>
|
|
214
|
+
numericAttributesForFiltering?: string[]
|
|
215
|
+
allowCompressionOfIntegerArray?: boolean
|
|
216
|
+
attributeForDistinct?: string
|
|
217
|
+
distinct?: boolean | number
|
|
218
|
+
replaceSynonymsInHighlight?: boolean
|
|
219
|
+
minProximity?: number
|
|
220
|
+
responseFields?: string[]
|
|
221
|
+
maxFacetHits?: number
|
|
222
|
+
paginationLimitedTo?: number
|
|
223
|
+
}
|
|
224
|
+
export declare interface AlgoliaTask {
|
|
225
|
+
taskID: number
|
|
226
|
+
objectID?: string
|
|
227
|
+
objectIDs?: string[]
|
|
228
|
+
createdAt?: string
|
|
229
|
+
updatedAt?: string
|
|
230
|
+
}
|
|
231
|
+
export default algolia;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//
|
|
2
|
+
// const host = searchEngine.openSearch?.host
|
|
3
|
+
// const protocol = searchEngine.openSearch?.protocol
|
|
4
|
+
// const port = searchEngine.openSearch?.port
|
|
5
|
+
// const auth = searchEngine.openSearch?.auth
|
|
6
|
+
//
|
|
7
|
+
// const client = new Client({
|
|
8
|
+
// node: `${protocol}://${auth}@${host}:${port}`,
|
|
9
|
+
// })
|
|
10
|
+
//
|
|
11
|
+
// async function search(index: string, params?: any) {
|
|
12
|
+
// const response = await client.search({
|
|
13
|
+
// index,
|
|
14
|
+
// body: params.query,
|
|
15
|
+
// })
|
|
16
|
+
//
|
|
17
|
+
// return response
|
|
18
|
+
// }
|
|
19
|
+
//
|
|
20
|
+
// async function createIndex(indexName: string, settings?: any): Promise<ApiResponse<any, any>> {
|
|
21
|
+
// return await client.indices.create({ index: indexName, body: settings })
|
|
22
|
+
// }
|
|
23
|
+
// // async function updateIndex(indexName: string, settings?: any): Promise<ApiResponse<any, any>> {
|
|
24
|
+
// // return await client.indices.update({ index: indexName, body: settings })
|
|
25
|
+
// // }
|
|
26
|
+
//
|
|
27
|
+
// async function deleteIndex(indexName: string): Promise<ApiResponse<any, any>> {
|
|
28
|
+
// return await client.indices.delete({ index: indexName })
|
|
29
|
+
// }
|
|
30
|
+
//
|
|
31
|
+
// async function addDocument(indexName: string, document: any): Promise<ApiResponse<any, any>> {
|
|
32
|
+
// return await client.index({
|
|
33
|
+
// id: document.id,
|
|
34
|
+
// index: indexName,
|
|
35
|
+
// body: document,
|
|
36
|
+
// refresh: true,
|
|
37
|
+
// })
|
|
38
|
+
// }
|
|
39
|
+
//
|
|
40
|
+
// async function deleteDocument(indexName: string, document: any): Promise<ApiResponse<any, any>> {
|
|
41
|
+
// return await client.delete({
|
|
42
|
+
// id: document.id,
|
|
43
|
+
// index: indexName,
|
|
44
|
+
// })
|
|
45
|
+
// }
|
|
46
|
+
//
|
|
47
|
+
declare const opensearch: SearchEngineDriver;
|
|
48
|
+
export default opensearch;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export declare function useAlgolia(): typeof algolia;
|
|
|
7
7
|
export declare function useMeilisearch(): typeof meilisearch;
|
|
8
8
|
export declare function useOpensearch(): typeof opensearch;
|
|
9
9
|
export type SearchDriver = 'meilisearch' | 'algolia' | 'opensearch';
|
|
10
|
-
export * from './documents';
|
|
10
|
+
export * from './documents/index';
|
|
11
11
|
export { algolia, meilisearch, opensearch };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/search-engine",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.70.
|
|
4
|
+
"version": "0.70.43",
|
|
5
5
|
"description": "The Stacks search engine integrations.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"prepublishOnly": "bun run build"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@stacksjs/config": "0.70.
|
|
57
|
+
"@stacksjs/config": "^0.70.43",
|
|
58
58
|
"better-dx": "^0.2.12"
|
|
59
59
|
}
|
|
60
60
|
}
|