Search for documents using Filter and Python

API version: 0.17.0

For search you can use our built-in filter function. In this demo you can examine how to use filter, and how to process the result.

import slamby_sdk
from slamby_sdk.rest import ApiException

client = slamby_sdk.ApiClient("https://europe.slamby.com/demo/")
client.set_default_header("Authorization", "Slamby s3cr3t")
client.set_default_header("X-DataSet", "demo")

filter = {
    "Filter" : {
        "TagIds" : [],
        "Query" : "demo"
    },
    "Pagination" : {
        "Offset" : 0,
        "Limit": 3,
        "OrderDirection" : "Asc",
        "OrderByField" : "title"
    }
}

try:
    result = slamby_sdk.DocumentApi(client).get_filtered_documents(filter_settings=filter)
    #print(result)
except ApiException as e:
    print(e)

# Print statistics
if result:
    total = result.total
    count = result.count
    found_documents = result.items

# Print document titles
if result:
    for item in result.items:
        print(item["title"])

Leave a Reply

Your email address will not be published. Required fields are marked *