typesense-instantsearch-adapter 2.5.0-6 → 2.5.0-7
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/dist/typesense-instantsearch-adapter.js +22 -6
- package/dist/typesense-instantsearch-adapter.js.map +1 -1
- package/dist/typesense-instantsearch-adapter.min.js +1 -1
- package/dist/typesense-instantsearch-adapter.min.js.map +1 -1
- package/index.d.ts +0 -1
- package/lib/Configuration.js +0 -2
- package/lib/Configuration.js.map +1 -1
- package/lib/SearchResponseAdapter.js +22 -4
- package/lib/SearchResponseAdapter.js.map +1 -1
- package/package.json +1 -1
- package/src/Configuration.js +1 -3
- package/src/SearchResponseAdapter.js +21 -4
|
@@ -2204,7 +2204,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2204
2204
|
var Configuration = /*#__PURE__*/function () {
|
|
2205
2205
|
function Configuration() {
|
|
2206
2206
|
var _this$server$cacheSea,
|
|
2207
|
-
_options$useHighlight,
|
|
2208
2207
|
_options$additionalSe,
|
|
2209
2208
|
_ref,
|
|
2210
2209
|
_this$additionalSearc,
|
|
@@ -2229,7 +2228,6 @@ var Configuration = /*#__PURE__*/function () {
|
|
|
2229
2228
|
}]
|
|
2230
2229
|
};
|
|
2231
2230
|
this.server.cacheSearchResultsForSeconds = (_this$server$cacheSea = this.server.cacheSearchResultsForSeconds) !== null && _this$server$cacheSea !== void 0 ? _this$server$cacheSea : 2 * 60;
|
|
2232
|
-
this.useHighlightV2Structure = (_options$useHighlight = options.useHighlightV2Structure) !== null && _options$useHighlight !== void 0 ? _options$useHighlight : true;
|
|
2233
2231
|
this.additionalSearchParameters = (_options$additionalSe = options.additionalSearchParameters) !== null && _options$additionalSe !== void 0 ? _options$additionalSe : {};
|
|
2234
2232
|
this.additionalSearchParameters.query_by = (_ref = (_this$additionalSearc = this.additionalSearchParameters.queryBy) !== null && _this$additionalSearc !== void 0 ? _this$additionalSearc : this.additionalSearchParameters.query_by) !== null && _ref !== void 0 ? _ref : "";
|
|
2235
2233
|
this.additionalSearchParameters.sort_by = (_ref2 = (_this$additionalSearc2 = this.additionalSearchParameters.sortBy) !== null && _this$additionalSearc2 !== void 0 ? _this$additionalSearc2 : this.additionalSearchParameters.sort_by) !== null && _ref2 !== void 0 ? _ref2 : "";
|
|
@@ -2856,9 +2854,10 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
|
|
|
2856
2854
|
key: "_adaptHighlightResult",
|
|
2857
2855
|
value: function _adaptHighlightResult(typesenseHit, snippetOrValue) {
|
|
2858
2856
|
var result = {}; // If there is a highlight object available (as of v0.24.0),
|
|
2857
|
+
// And the highlight object uses the highlight format available in v0.24.0.rcn32 and above
|
|
2859
2858
|
// use that instead of the highlights array, since it supports highlights of nested fields
|
|
2860
2859
|
|
|
2861
|
-
if (
|
|
2860
|
+
if (typesenseHit.highlight != null && this.isHighlightPost0240RCN32Format(typesenseHit.highlight)) {
|
|
2862
2861
|
this.adaptHighlightObject(typesenseHit, result, snippetOrValue);
|
|
2863
2862
|
} else {
|
|
2864
2863
|
this.adaptHighlightsArray(typesenseHit, result, snippetOrValue);
|
|
@@ -2866,6 +2865,11 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
|
|
|
2866
2865
|
|
|
2867
2866
|
return result;
|
|
2868
2867
|
}
|
|
2868
|
+
}, {
|
|
2869
|
+
key: "isHighlightPost0240RCN32Format",
|
|
2870
|
+
value: function isHighlightPost0240RCN32Format(highlight) {
|
|
2871
|
+
return highlight.full == null && highlight.snippet == null;
|
|
2872
|
+
}
|
|
2869
2873
|
}, {
|
|
2870
2874
|
key: "adaptHighlightsArray",
|
|
2871
2875
|
value: function adaptHighlightsArray(typesenseHit, result, snippetOrValue) {
|
|
@@ -2908,7 +2912,9 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
|
|
|
2908
2912
|
matchedWords = v.matchedWords,
|
|
2909
2913
|
matchedIndices = v.matchedIndices;
|
|
2910
2914
|
|
|
2911
|
-
if (
|
|
2915
|
+
if (value == null) {
|
|
2916
|
+
result[attribute] = _this3._adaptHighlightNullValue();
|
|
2917
|
+
} else if (Array.isArray(value)) {
|
|
2912
2918
|
// Algolia lists all values of the key in highlights, even those that don't have any highlights
|
|
2913
2919
|
// So add all values of the array field, including highlights
|
|
2914
2920
|
result[attribute] = [];
|
|
@@ -2919,6 +2925,11 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
|
|
|
2919
2925
|
matchLevel: matchLevel,
|
|
2920
2926
|
matchedWords: matchedWords[index]
|
|
2921
2927
|
});
|
|
2928
|
+
} else if ((0,_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__["default"])(unhighlightedValueFromArray) === "object") {
|
|
2929
|
+
// Handle arrays of objects
|
|
2930
|
+
// Side note: Typesense does not support highlights for nested objects in this `highlights` array,
|
|
2931
|
+
// so we pass in an empty object below
|
|
2932
|
+
result[attribute].push(_this3._adaptHighlightInObjectValue(unhighlightedValueFromArray, {}, snippetOrValue));
|
|
2922
2933
|
} else {
|
|
2923
2934
|
result[attribute].push({
|
|
2924
2935
|
value: "".concat(unhighlightedValueFromArray),
|
|
@@ -2927,6 +2938,11 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
|
|
|
2927
2938
|
});
|
|
2928
2939
|
}
|
|
2929
2940
|
});
|
|
2941
|
+
} else if ((0,_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__["default"])(value) === "object") {
|
|
2942
|
+
// Handle nested objects
|
|
2943
|
+
// Side note: Typesense does not support highlights for nested objects in this `highlights` array,
|
|
2944
|
+
// so we pass in an empty object below
|
|
2945
|
+
result[attribute] = _this3._adaptHighlightInObjectValue(value, {}, snippetOrValue);
|
|
2930
2946
|
} else {
|
|
2931
2947
|
// Convert all values to strings
|
|
2932
2948
|
result[attribute].value = _this3._adaptHighlightTag("".concat(value), _this3.instantsearchRequest.params.highlightPreTag, _this3.instantsearchRequest.params.highlightPostTag);
|
|
@@ -2998,8 +3014,8 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
|
|
|
2998
3014
|
if (highlightPrimitiveValue != null) {
|
|
2999
3015
|
return {
|
|
3000
3016
|
value: this._adaptHighlightTag("".concat(highlightPrimitiveValue[snippetOrValue]), this.instantsearchRequest.params.highlightPreTag, this.instantsearchRequest.params.highlightPostTag),
|
|
3001
|
-
matchLevel: "full",
|
|
3002
|
-
matchedWords: highlightPrimitiveValue.matched_tokens
|
|
3017
|
+
matchLevel: (highlightPrimitiveValue.matched_tokens || []).length > 0 ? "full" : "none",
|
|
3018
|
+
matchedWords: highlightPrimitiveValue.matched_tokens || []
|
|
3003
3019
|
};
|
|
3004
3020
|
} else {
|
|
3005
3021
|
return {
|