-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(algolia): add custom attributes to backend and core methods (#9730)
- Loading branch information
Showing
5 changed files
with
90 additions
and
6 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| from __future__ import annotations # noqa: INP001 | ||
|
|
||
| import os | ||
|
|
||
| from algoliasearch.search_client import SearchClient | ||
|
|
||
| api_key = os.environ["ALGOLIA_WRITE_API_KEY"] | ||
| app_id = os.environ["ALGOLIA_APP_ID"] | ||
| index_name = os.environ["ALGOLIA_INDEX"] | ||
|
|
||
|
|
||
| def main(): | ||
| client = SearchClient.create(app_id, api_key) | ||
| index = client.init_index(index_name) | ||
|
|
||
| # Core is a custom attribute set to denote whether a record is part | ||
| # of the base expression API, we sort descending so those methods | ||
| # show up first in search instead of backend-specific methods | ||
| override_default_settings = { | ||
| "ranking": [ | ||
| "typo", | ||
| "words", | ||
| "desc(core)", | ||
| "filters", | ||
| "proximity", | ||
| "attribute", | ||
| "exact", | ||
| ] | ||
| } | ||
|
|
||
| index.set_settings(override_default_settings) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
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
File renamed without changes.
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