Closed Patrick386 closed 2 years ago
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; }
attributesForFaceting I found that I need to set this option. 'facetFilter' This filter works. You may close this.
attributesForFaceting: [ 'uid', ],
I want to filter and import only the products I have registered.
Flutter Web:
Package algolia: ^1.1.1
Cloud Functions
Client