-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
👽 replace dart_algolia with algoliasearch
Showing
5 changed files
with
164 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
import 'package:algolia/algolia.dart' | ||
show Algolia, AlgoliaQuery, AlgoliaQuerySnapshot; | ||
import 'package:algoliasearch/algoliasearch_lite.dart'; | ||
|
||
import '../env/env.dart'; | ||
import '../models/search_result.dart'; | ||
|
||
class AlgoliaSearch { | ||
AlgoliaSearch._(); | ||
const AlgoliaSearch._(); | ||
|
||
static final Algolia _algolia = Algolia.init( | ||
applicationId: Env.algoliaApplicationId, | ||
static final SearchClient _client = SearchClient( | ||
appId: Env.algoliaApplicationId, | ||
apiKey: Env.algoliaSearchOnlyApiKey, | ||
); | ||
|
||
static Future<AlgoliaQuerySnapshot> query(String queryString) async { | ||
final AlgoliaQuery query = _algolia.instance | ||
.index(Env.algoliaSearchIndex) | ||
.query(queryString) | ||
.setAttributesToRetrieve(SearchResult.attributesToRetrieve) | ||
.setPage(0) | ||
.setHitsPerPage(100); | ||
static Future<SearchResponse> query(String queryString) => | ||
_client.searchIndex( | ||
request: SearchForHits( | ||
indexName: Env.algoliaSearchIndex, | ||
query: queryString, | ||
attributesToRetrieve: SearchResult.attributesToRetrieve, | ||
page: 0, | ||
hitsPerPage: 100, | ||
), | ||
); | ||
|
||
return await query.getObjects(); | ||
} | ||
static dispose() => _client.dispose(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters