DEV Community

Cover image for AlgoliaQB - First Release
Taylor Brazelton
Taylor Brazelton

Posted on

 

AlgoliaQB - First Release

Today I am releasing the first version of Algolia Query Builder. Its purpose is to make generating a filter query easier. You can then pass the generated query directly into the algoliasearch search function. Hopefully, this can help make others' lives easier as well as my own.

Installation:

pip install algoliaqb
Enter fullscreen mode Exit fullscreen mode

Usage Example:

from algoliasearch.search_client import SearchClient
from algoliaqb import AlgoliaQueryBuilder
from flask import request


aqb = AlgoliaQueryBuilder(
    search_param="search",
    filter_map={
        "group_id": "tenant_id",
        "is_reported": "is_reported"
    }
)

# Extract the search query from our flask apps request.args var.
search_query = aqb.get_search_query(request.args)
# Get the filter query from our request args.
filter_query = aqb.get_filter_query(request.args)

# Now that we have the filter string, we just pass it into the search function.

search_client = SearchClient()
index = search_client.init_index("contacts")
results = index.search(search_query, {"filters": filter_query})
Enter fullscreen mode Exit fullscreen mode

For more information please checkout Github or Pypi.

Top comments (0)

An Animated Guide to Node.js Event Loop

>> Check out this classic DEV post <<