Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jupyter-naas
GitHub Repository: jupyter-naas/awesome-notebooks
Path: blob/master/Algolia/Algolia_List indices.ipynb
2973 views
Kernel: Python 3

Algolia.png

Algolia - List indices

Give Feedback | Bug report

Tags: #algolia #python #api #index #list

Last update: 2023-11-21 (Created: 2023-06-15)

Description: This notebook shows how to get a list of indices with their associated metadata from Algolia using Python. This method retrieves a list of all indices associated with a given Application ID. The returned list includes the names of the indices as well as their associated metadata, such as the number of records, size, and last build time.

Input

Import libraries

try: from algoliasearch.search_client import SearchClient except: !pip install algoliasearch --user from algoliasearch.search_client import SearchClient import naas

Setup variables

  • app_id: Algolia application ID.

  • api_key: Algolia API key.

app_id = naas.secret.get("ALGOLIA_APP_ID") or "<YOUR_APP_ID>" api_key = naas.secret.get("ALGOLIA_API_KEY") or "<YOUR_API_KEY>"

Model

Connect to Algolia

# Initialize the Algolia client client = SearchClient.create(app_id, api_key)

List indices

indices = client.list_indices() indices

Output

Display outputs

print("Indices fetched:", len(indices.get("items"))) indices.get("items")