typesense-instantsearch-adapter 2.7.1-0 → 2.7.1-2

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/README.md CHANGED
@@ -472,17 +472,17 @@ const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
472
472
  const searchClient = typesenseInstantsearchAdapter.searchClient;
473
473
  const search = instantsearch({
474
474
  searchClient,
475
- indexName: 'products',
475
+ indexName: "products",
476
476
  routing: true,
477
477
  async searchFunction(helper) {
478
478
  const query = helper.getQuery().query;
479
479
  const page = helper.getPage(); // Retrieve the current page
480
480
  const totalNearestNeighborsToFetch = 1000;
481
481
 
482
- if (query !== '') {
482
+ if (query !== "") {
483
483
  // Get embedding for the query
484
484
  let response = await fetch(
485
- 'http://localhost:8000/embedding?' + new URLSearchParams({ q: query }) // <=== Embedding API
485
+ "http://localhost:8000/embedding?" + new URLSearchParams({ q: query }) // <=== Embedding API
486
486
  );
487
487
 
488
488
  let parsedResponse = await response.json();
@@ -492,16 +492,13 @@ const search = instantsearch({
492
492
  // Send the embedding to Typesense to do a nearest neighbor search
493
493
  helper
494
494
  .setQueryParameter(
495
- 'typesenseVectorQuery', // <=== Special parameter that only works in typesense-instantsearch-adapter@2.7.0-3 and above
496
- `vectors:([${parsedResponse['embedding'].join(',')}], k:${totalNearestNeighborsToFetch})`
495
+ "typesenseVectorQuery", // <=== Special parameter that only works in typesense-instantsearch-adapter@2.7.0-3 and above
496
+ `vectors:([${parsedResponse["embedding"].join(",")}], k:${totalNearestNeighborsToFetch})`
497
497
  )
498
498
  .setPage(page)
499
499
  .search();
500
500
  } else {
501
- helper
502
- .setQueryParameter('typesenseVectorQuery', null)
503
- .setPage(page)
504
- .search();
501
+ helper.setQueryParameter("typesenseVectorQuery", null).setPage(page).search();
505
502
  }
506
503
  },
507
504
  });
@@ -2970,7 +2970,7 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
2970
2970
  adaptedHit._highlightResult = _this2._adaptHighlightResult(typesenseHit, "value");
2971
2971
  adaptedHit._rawTypesenseHit = typesenseHit; // Add metadata fields to result, if a field with that name doesn't already exist
2972
2972
 
2973
- ["text_match", "geo_distance_meters", "curated", "text_match_info"].forEach(function (metadataField) {
2973
+ ["text_match", "geo_distance_meters", "curated", "text_match_info", "hybrid_search_info", "vector_distance"].forEach(function (metadataField) {
2974
2974
  if (Object.keys(typesenseHit).includes(metadataField) && !Object.keys(adaptedHit).includes(metadataField)) {
2975
2975
  adaptedHit[metadataField] = typesenseHit[metadataField];
2976
2976
  }
@@ -3211,9 +3211,9 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
3211
3211
  return fc["field_name"];
3212
3212
  }).concat(this.allTypesenseResponses.map(function (r) {
3213
3213
  return r.facet_counts || [];
3214
- }).map(function (fc) {
3214
+ }).flat().map(function (fc) {
3215
3215
  return fc["field_name"];
3216
- }).flat().filter(function (f) {
3216
+ }).filter(function (f) {
3217
3217
  return f;
3218
3218
  }))));
3219
3219
  }