0

I am trying to do refinement in meilisearch.

const search = instantsearch({
        indexName: "books",
        searchClient: instantMeiliSearch(
            "https://example.com",
            "XXXXXXXXXXX",
        ),
         searchParameters: {
        attributesForFaceting: ['title']
    } 
        });

 instantsearch.widgets.refinementList({
            container: '#brand-list',
            attribute: 'title',
           
          }),

I am keep getting error 'Can't perform facet count, as no facet is set'. I do not know what I am doing wrong, any help would be great.

Thanks in advance.

sanj
  • 1
  • 2

1 Answers1

0

You must add attributesForFacetting to the settings to be able to perform a search with facet filters. Check the dedicated section of the documentation: https://docs.meilisearch.com/reference/features/faceted_search.html#setting-up-facets

CaroFG
  • 407
  • 2
  • 5
  • can you please help me with syntax, I mean where and how? – sanj May 05 '21 at 09:03
  • Do you have a running instance of MeiliSearch? How do you add documents to it? – CaroFG May 05 '21 at 09:10
  • Here is a quick [start](https://docs.meilisearch.com/learn/getting_started/quick_start.html#download-and-launch) to install and launch MeiliSearch. To update the attributesForFaceting in the settings you can use cURL or the language you prefer, check [this example](https://docs.meilisearch.com/learn/getting_started/quick_start.html#download-and-launch) – CaroFG May 05 '21 at 09:18
  • yes, I have MeiliSearch server and Document is added from Laravel. php artisan scout:index books This command adds books as a index. – sanj May 05 '21 at 09:20
  • Okay. So setting facet is one time process right? – sanj May 05 '21 at 09:24
  • You just have to specify which fields you want to be able to use as facets in the settings once, and then you can use the facet filters on search whenever you want. – CaroFG May 05 '21 at 09:26
  • It is highly recommended to set the settings first before indexing the documents, it would be much faster :) – CaroFG May 05 '21 at 09:27
  • hi @caroFG I have price attribute for Min and Max price search but I came to know it numeric value cannot be set in facet ? is it true? – sanj May 12 '21 at 17:28
  • As I told you in your other post. The current version v0.20.0 doesn't take numeric values as facets, but the new engine that will be released in the v0.21.0 will :) – CaroFG May 12 '21 at 17:58