Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.lambdadb.ai/llms.txt

Use this file to discover all available pages before exploring further.

LambdaDB allows you to add one or more sorts on specific fields. Each sort can be reversed as well. The sort is defined on a per field level.
Sorting can be done on the following data types:
  • long
  • double
  • datetime
  • keyword

Parameters

ParameterDescriptionTypeRequiredValues
fieldField name to sort bystring-
orderSort order directionstringasc, desc

Sort order options

ValueDescription
ascSorts in ascending order
descSorts in descending order

Usage

The sort parameter accepts an array of sort objects, allowing multiple field sorting with different orders.
from lambdadb import LambdaDB

with LambdaDB(
    project_api_key="YOUR_API_KEY",
    base_url="YOUR_BASE_URL",
    project_name="YOUR_PROJECT_NAME",
) as client:
    coll = client.collection(collection_name)
    results = coll.query(
        query={"queryString": {"query": "*:*"}},
        size=10,
        sort=[{"field1": "desc"}, {"field2": "asc"}],
    )

Examples

Single field sort

Sort by timestamp in descending order (newest first):
[{"timestamp": "desc"}]

Multiple field sort

Sort by priority (descending) first, then by created_at (ascending):
[{"priority": "desc"}, {"created_at": "asc"}]
When multiple sort fields are specified, the sorting is applied in the order they appear in the array. Documents are first sorted by the first field, then by the second field for documents with the same first field value, and so on.