OpenSearchMemory / Paginator / SearchEvents

SearchEvents

class OpenSearchMemory.Paginator.SearchEvents
paginator = client.get_paginator('search_events')
paginate(**kwargs)

Creates an iterator that will paginate through responses from OpenSearchMemory.Client.search_events().

See also: AWS API Documentation

Request Syntax

response_iterator = paginator.paginate(
    spaceId='string',
    actorId='string',
    sessionIds=[
        'string',
    ],
    query={...}|[...]|123|123.4|'string'|True|None,
    sort={...}|[...]|123|123.4|'string'|True|None,
    PaginationConfig={
        'MaxItems': 123,
        'PageSize': 123,
        'StartingToken': 'string'
    }
)
Parameters:
  • spaceId (string) –

    [REQUIRED]

    The space whose events to search. Use actorId and sessionIds to narrow the search within it.

  • actorId (string) –

    [REQUIRED]

    The actor whose events to search (exact match). Required: every search covers exactly one actor, and an event stored without an actor is never returned. Narrow the search further with sessionIds, combined by AND. This is the only way to filter by actor: a query that references system_metadata.actor_id fails with ValidationException (reason nonFilterableField).

  • sessionIds (list) –

    Returns only events from one of these sessions (exact match). Combined with actorId by AND. Omit for no session filter. An empty list fails validation. An event stored without a session never matches a session filter. This is the only way to filter by session: a query that references system_metadata.session_id fails with ValidationException (reason nonFilterableField).

    • (string) –

      The ID of a session, which groups an actor’s events.

  • query (document) –

    [REQUIRED]

    The query: a subset of the OpenSearch Query DSL (see SearchQuery), validated by the same rules as on SearchMemories. Query event text as text and embeddings as vector. A search covers both conversation turns and chunks of documents submitted as a blob. You can’t use actor and session fields here. Use the top-level actorId and sessionIds.

    To search only the content of particular events, filter on event_ids with term or terms, for example with the sourceEventIds that a SearchMemories result returns. A terms clause on event_ids can list up to 10 event IDs. More IDs fail with ValidationException (reason queryBodyTooLarge). You can use event_ids only in term, terms, and exists queries.

  • sort (document) – The sort order (see SearchSort). Omit to return the most relevant events first.

  • PaginationConfig (dict) –

    A dictionary that provides parameters to control pagination.

    • MaxItems (integer) –

      The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken will be provided in the output that you can use to resume pagination.

    • PageSize (integer) –

      The size of each page.

    • StartingToken (string) –

      A token to specify where to start paginating. This is the NextToken from a previous response.

Return type:

dict

Returns:

Response Syntax

{
    'events': [
        {
            'eventId': 'string',
            'score': 123.0,
            'systemMetadata': {
                'actorId': 'string',
                'sessionId': 'string',
                'createdAt': datetime(2015, 1, 1),
                'updatedAt': datetime(2015, 1, 1)
            },
            'metadata': {
                'string': 'string'
            },
            'matchedContent': 'string'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) –

    • events (list) –

      The matching event chunks, in the order sort requests, or most relevant first when it has none. Empty when nothing matches. Each result is the matching chunk of an event. Call GetEvent for the whole event.

      • (dict) –

        A SearchEvents result: the matching chunk of an event and its provenance. Unlike EventSummary from ListEvents, it has a relevance score and the matched content, but not the full payload.

        • eventId (string) –

          The ID of the event that the chunk belongs to. Use it with GetEvent or DeleteEvent.

        • score (float) –

          The relevance score of the result. A higher score is more relevant. Scores aren’t normalized to a fixed range and can be greater than 1, so use them only to order results.

        • systemMetadata (dict) –

          Provenance for the chunk: the owning actor and session, and when it was created and last updated. It is the same block that ListMemories and SearchMemories return. Event chunks are never modified, so updatedAt always equals createdAt.

          Absent when the service has no provenance for the chunk.

          • actorId (string) –

            The owning actor. Absent when none was recorded.

          • sessionId (string) –

            The owning session. Absent when none was recorded.

          • createdAt (datetime) –

            When the record was created. Always present on ListMemories and GetMemory. It can be absent from search results.

          • updatedAt (datetime) –

            When the record was last updated. Equals createdAt for a record that has never been updated, and always for a SearchEvents result.

        • metadata (dict) –

          The event’s metadata tags. All values are strings. In a query, filter on a tag as metadata.<key>.

          • (string) –

            A metadata key: letters, digits, hyphens ( -), and underscores ( _). Dots are not allowed, because a query uses dots to separate nested field names.

            • (string) –

              The value of a metadata entry.

        • matchedContent (string) –

          The text of the matching chunk.

    • NextToken (string) –

      A token to resume pagination.