Giter Site home page Giter Site logo

Comments (9)

Bones5 avatar Bones5 commented on May 30, 2024 1

Thank you, I see my error now.

I thought the function operated on each record individually rather than receiving an array of all the records.

That makes a lot more sense.

from firestore-algolia-search.

Haroenv avatar Haroenv commented on May 30, 2024 1

Sorry for explaining wrong, I think it makes sense as a feature request!

from firestore-algolia-search.

Bones5 avatar Bones5 commented on May 30, 2024 1

Thanks for your help @Haroenv

I got there in the end. I spent a lot of time trying to apply the API configuration when it was the was the Configure component I really needed.

<Configure facetFilters={[["isPublished:true"]]} /> 👍

from firestore-algolia-search.

Haroenv avatar Haroenv commented on May 30, 2024

What do you return from the transform function? This plugin reads .result of the response of the function. If you don't want to keep any, if I understand it correctly that response should be { result: [] }

const response = await fetch(`https://${config.location}-${config.projectId}.cloudfunctions.net/${config.transformFunction}`, {
method: 'post',
body: JSON.stringify({ data: payload }),
headers: { 'Content-Type': 'application/json' },
});
const data = await response?.json();
return data.result;

from firestore-algolia-search.

Haroenv avatar Haroenv commented on May 30, 2024

I'll close this issue now, but if you have further questions, feel free to ask!

from firestore-algolia-search.

Bones5 avatar Bones5 commented on May 30, 2024

OK, so having looked at this further it appears the transform function is applied to each individual record as described in the ReadMe.

(My biggest problem was actually that my function was in Europe-West-1 not Europe-West-2 and that returned the JSON error. Whoops.)

What I want to do is this:

import * as functions from "firebase-functions";

const searchIndexing = functions
  .region("europe-west2")
  .https.onCall((record: any, context) => {
    if (record.isPublished) {
      return record;
    } else {

      // Do not index this record or remove if it is already present
      
      return;
    }
  });

Having looked at the extension it looks like this is not possible at the moment as the transform function is applied after the decision to Create or Delete from Algolia.

Is there a better way to do this or should this be a feature request?

from firestore-algolia-search.

smomin avatar smomin commented on May 30, 2024

Hello @Bones5

Algolia Search configuration provides a way to filter your search results by using filtering or Query rules. I would recommend this approach. I am hesitant to add code for this use case. Also, I would also suggest not sending attributes in the search results that might not be relevant in the search experience, https://www.algolia.com/doc/api-reference/api-parameters/unretrievableAttributes/.

Let me know if you have any questions.

Sajid

from firestore-algolia-search.

Bones5 avatar Bones5 commented on May 30, 2024

Thanks for your reply @smomin

It does look like this is typically done in Algolia. It is similar to an "inStock" for something like Shopify.

Looking at this example it is applied in at during the index https://www.algolia.com/doc/api-reference/api-parameters/numericFilters/#examples

I'm a bit confused how to replicate this using the plugin, do you know where I would add this search to the index?

from firestore-algolia-search.

Haroenv avatar Haroenv commented on May 30, 2024

If you have the "in stock" attribute as a key of the object/record, you can set it as attributesForFaceting and use filters frontend to hide or display those: facetFilters: [['inStock:true']] for example. You can also use InstantSearch' toggleRefinement or refinementList for making the UI

from firestore-algolia-search.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.