Node.js Implementation of Search not working

Hi!

I followed this article, and it looks like it works, except I can’t specify any attributes without Algolia returning empty results.

When I run:

client.search("RESULTS", {
    query: "best",
    page: 0,
    hitsPerPage: 10,
    facets: "username",
    facetFilters: "username:john",
})
    .then(
        console.log
    )
    .catch(
        console.log
    );


I’m expecting a few results, and I can confirm this since I have a working Algolia search client on my front end, but this is on my backend.

I want to search for any results where “username” equals “john”. I’ve already done all the configuration on the Algolia dashboard, and like i said, works perfectly on my front end app.

I know the API keys are also correct, because I removed all the attributes and I did get some results, but I only want filtered results using facets.

What am doing wrong?

For some context, this is what my React app looks like:

<SearchContainer>
        <InstantSearch 
          searchClient={searchClient} 
          indexName="RESULTS"
          searchState={{
            query: `${query}`
          }}  
        >
          <RefinementList
            attribute={"username"}
            defaultRefinement={["john"]}
          />

And it works as expected.

Thanks in advanced!

Hi @focushero

Sorry for the late response – is this still an issue? Can you maybe show the payload from the front end and back end searches?

I notice a coupe things in your backend search –

  1. You have the query hardcoded as “best” – should that return results?
  2. You are using both facetsparameter and afacetFiltersparameter.facetsis used for searching [within facet attributes](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#retrieving-facets), whilefacetFilters` is used at search time to retrieve records.

Try removing the facets parameter and confirm the query “best” should actually return records.