@reactionary/meilisearch 0.8.0 → 0.9.1
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.
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
success,
|
|
18
18
|
AddressIdentifierSchema
|
|
19
19
|
} from "@reactionary/core";
|
|
20
|
-
import {
|
|
20
|
+
import { Meilisearch } from "meilisearch";
|
|
21
21
|
class MeilisearchOrderSearchCapability extends OrderSearchCapability {
|
|
22
22
|
config;
|
|
23
23
|
factory;
|
|
@@ -54,7 +54,7 @@ class MeilisearchOrderSearchCapability extends OrderSearchCapability {
|
|
|
54
54
|
return searchOptions;
|
|
55
55
|
}
|
|
56
56
|
async queryByTerm(payload) {
|
|
57
|
-
const client = new
|
|
57
|
+
const client = new Meilisearch({
|
|
58
58
|
host: this.config.apiUrl,
|
|
59
59
|
apiKey: this.config.apiKey
|
|
60
60
|
});
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ImageSchema,
|
|
4
4
|
ProductSearchResultItemVariantSchema
|
|
5
5
|
} from "@reactionary/core";
|
|
6
|
-
import {
|
|
6
|
+
import { Meilisearch } from "meilisearch";
|
|
7
7
|
import { getProductIndexNameForLocale } from "../core/index-utils.js";
|
|
8
8
|
class MeilisearchProductRecommendationsCapability extends ProductRecommendationsCapability {
|
|
9
9
|
config;
|
|
@@ -23,7 +23,7 @@ class MeilisearchProductRecommendationsCapability extends ProductRecommendations
|
|
|
23
23
|
* Uses semantic search to find visually or data-wise similar products
|
|
24
24
|
*/
|
|
25
25
|
async getSimilarProductsRecommendations(query) {
|
|
26
|
-
const client = new
|
|
26
|
+
const client = new Meilisearch({
|
|
27
27
|
host: this.config.apiUrl,
|
|
28
28
|
apiKey: this.config.apiKey
|
|
29
29
|
});
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
Reactionary,
|
|
23
23
|
success
|
|
24
24
|
} from "@reactionary/core";
|
|
25
|
-
import {
|
|
25
|
+
import { Meilisearch } from "meilisearch";
|
|
26
26
|
import { getProductIndexNameForLocale } from "../core/index-utils.js";
|
|
27
27
|
class MeilisearchProductSearchCapability extends ProductSearchCapability {
|
|
28
28
|
config;
|
|
@@ -57,13 +57,29 @@ class MeilisearchProductSearchCapability extends ProductSearchCapability {
|
|
|
57
57
|
};
|
|
58
58
|
if (this.config.useAIEmbedding) {
|
|
59
59
|
searchOptions.hybrid = {
|
|
60
|
-
embedder: this.config.useAIEmbedding
|
|
60
|
+
embedder: this.config.useAIEmbedding,
|
|
61
|
+
semanticRatio: this.config.semanticRatio
|
|
62
|
+
// This can be adjusted based on how much weight you want to give to semantic relevance vs keyword matching
|
|
61
63
|
};
|
|
62
64
|
}
|
|
65
|
+
if (payload.personalizationProfile) {
|
|
66
|
+
let blurb = payload.personalizationProfile.blurb || "";
|
|
67
|
+
if (blurb.length > 500) {
|
|
68
|
+
blurb = blurb.substring(0, 500);
|
|
69
|
+
}
|
|
70
|
+
if (!blurb) {
|
|
71
|
+
blurb = "The customer is in the following segments: " + payload.personalizationProfile.segments.join(", ");
|
|
72
|
+
}
|
|
73
|
+
if (blurb) {
|
|
74
|
+
searchOptions.personalize = {
|
|
75
|
+
userContext: blurb
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
63
79
|
return searchOptions;
|
|
64
80
|
}
|
|
65
81
|
async queryByTerm(payload) {
|
|
66
|
-
const client = new
|
|
82
|
+
const client = new Meilisearch({
|
|
67
83
|
host: this.config.apiUrl,
|
|
68
84
|
apiKey: this.config.apiKey
|
|
69
85
|
});
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/meilisearch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"vitest": "^4.0.9",
|
|
9
9
|
"@nx/vite": "22.4.5",
|
|
10
|
-
"@reactionary/core": "0.
|
|
10
|
+
"@reactionary/core": "0.9.1",
|
|
11
11
|
"zod": "4.1.9",
|
|
12
|
-
"meilisearch": "^0.
|
|
12
|
+
"meilisearch": "^0.58.0"
|
|
13
13
|
},
|
|
14
14
|
"sideEffects": false
|
|
15
15
|
}
|
|
@@ -5,6 +5,7 @@ const MeilisearchConfigurationSchema = z.looseObject({
|
|
|
5
5
|
indexName: z.string(),
|
|
6
6
|
orderIndexName: z.string(),
|
|
7
7
|
useAIEmbedding: z.string().optional(),
|
|
8
|
+
semanticRatio: z.number().default(0.5).meta({ description: "The ratio of semantic relevance to keyword matching when using AI embeddings. This can be adjusted based on how much weight you want to give to semantic relevance vs keyword matching in search results." }),
|
|
8
9
|
useRecommendationsForBots: z.boolean().default(false).meta({ description: "Whether to use recommendations for bot traffic. By default, recommendations are not used for bots to save on API costs, but enabling this can provide a better experience for bot traffic such as search engine crawlers." })
|
|
9
10
|
});
|
|
10
11
|
export {
|
|
@@ -5,6 +5,7 @@ export declare const MeilisearchConfigurationSchema: z.ZodObject<{
|
|
|
5
5
|
indexName: z.ZodString;
|
|
6
6
|
orderIndexName: z.ZodString;
|
|
7
7
|
useAIEmbedding: z.ZodOptional<z.ZodString>;
|
|
8
|
+
semanticRatio: z.ZodDefault<z.ZodNumber>;
|
|
8
9
|
useRecommendationsForBots: z.ZodDefault<z.ZodBoolean>;
|
|
9
10
|
}, z.core.$loose>;
|
|
10
11
|
export type MeilisearchConfiguration = z.infer<typeof MeilisearchConfigurationSchema>;
|