Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filterOnly ? #64

Open
Patrick386 opened this issue Mar 11, 2023 · 3 comments
Open

filterOnly ? #64

Patrick386 opened this issue Mar 11, 2023 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@Patrick386
Copy link

Cloud functions

  • IndexName: company
  • filterOnly(status)
  • filterOnly(published)

attributesForFaceting: [ ‘filterOnly(status)’, ‘filterOnly(published)’, ],

client:

  HitsSearcher hitsSearcher = HitsSearcher.create(
      applicationID: AlgoliaCredentials.applicationID,
      apiKey: AlgoliaCredentials.apiKey,
      state:  const SearchState(
        indexName: 'company',
        facetFilters: ['published:true'],
        //query: '',
      ));

I want to create a page that has status ‘processing’ and published ‘true’. How do I do that?

@VladislavFitz VladislavFitz self-assigned this May 26, 2023
@VladislavFitz
Copy link
Contributor

Hi @Patrick386 ,
Sorry for late reaction.
The recommended way to do it is to use the filters value of the SearchState.
Your code should look as follows:

 HitsSearcher hitsSearcher = HitsSearcher.create(
      applicationID: AlgoliaCredentials.applicationID,
      apiKey: AlgoliaCredentials.apiKey,
      state:  const SearchState(
        indexName: 'company',
        filters: 'published:true AND status:processing',
        //query: '',
      ));

Otherwise you can use the FilterState component connected to your HitsSearcher instance, which simplified the filter management.

@VladislavFitz VladislavFitz added the question Further information is requested label May 26, 2023
@Abhishek-Acme
Copy link

@VladislavFitz the filters param in not there in SearchState

@Patrick386
Copy link
Author

Hi @Patrick386 , Sorry for late reaction. The recommended way to do it is to use the filters value of the SearchState. Your code should look as follows:

 HitsSearcher hitsSearcher = HitsSearcher.create(
      applicationID: AlgoliaCredentials.applicationID,
      apiKey: AlgoliaCredentials.apiKey,
      state:  const SearchState(
        indexName: 'company',
        filters: 'published:true AND status:processing',
        //query: '',
      ));

Otherwise you can use the FilterState component connected to your HitsSearcher instance, which simplified the filter management.

Thank you for your answer.
By the way, the following code is the one I am currently using.

  final FilterState filterState = FilterState()
    ..add(mainCategoryGroupID, [Filter.facet('mainCategory', category.main)])
    ..add(subCategoryGroupID, [])
    ..add(typeGroupID, [])
    ..add(tagGroupID, []);

  HitsSearcher hitsSearcher = HitsSearcher(
    applicationID: AlgoliaCredentials.applicationID,
    apiKey: AlgoliaCredentials.apiKey,
    indexName: AlgoliaCredentials.discoveryIndex,
  )..connectFilterState(filterState);

I will try applying the recommended code. Thank you for your helpful response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants