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

facetFilter does not work. #100

Closed
Patrick386 opened this issue Sep 17, 2022 · 1 comment
Closed

facetFilter does not work. #100

Patrick386 opened this issue Sep 17, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@Patrick386
Copy link

Patrick386 commented Sep 17, 2022

I want to filter and import only the products I have registered.

Flutter Web:

[✓] Flutter (Channel stable, 3.3.2, on macOS 12.5.1 21G83 darwin-arm (Rosetta), locale ko-KR)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.2.2)
[✓] VS Code (version 1.71.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!

Package
algolia: ^1.1.1

Cloud Functions

requestIndex.setSettings({
  searchableAttributes: [
   'title',   
  ],
attributesForFaceting: [   <<<--- add
    'uid',
  ],
  ranking: [
    'desc(popularity)',
    'desc(vote_count)',
    'desc(vote_average)',
    'typo',
    'words',
    'filters',
    'geo',
    'proximity',
    'attribute',
    'exact',
    'custom',
  ],
});

Client

  AlgoliaIndexReference get _collectionIndex => _algolia.instance.index('products');

  Future<List<ProductData>> performProductQuery(String text) async {

    String uid = 'ODCpjfJWUTOMTIpIZ77Gql0HH9y1';  // user id

    AlgoliaQuery query = _collectionIndex.query(text);
    query = query.facetFilter('uid:$uid');

    logger.info('$query');  // ok

    final AlgoliaQuerySnapshot snap = await query.getObjects();
    final List<ProductData> result  = snap.hits.map((AlgoliaObjectSnapshot e) =>  ProductData.fromJson(e.data)).toList();

    logger.info(result);  // []
    return result;
  }
@Patrick386 Patrick386 added the bug Something isn't working label Sep 17, 2022
@Patrick386
Copy link
Author

Patrick386 commented Oct 4, 2022

attributesForFaceting I found that I need to set this option.
'facetFilter' This filter works. You may close this.

 attributesForFaceting: [
    'uid',
  ],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants