search_memories
async
¶
search_memories(
space_id: SpaceId,
actor_id: ActorId,
query: SearchQuery,
*,
config_overrides: Optional[AsyncOpenSearchMemoryClientConfig] = None,
memory_strategies: Optional[StrategySelectorList] = None,
sort: Optional[SearchSort] = None,
max_results: Optional[MaxResults] = None,
next_token: Optional[PaginationToken] = None,
) -> SearchMemoriesOutput
Searches a space's memories by relevance. The query is a subset of the OpenSearch Query DSL. The service validates it, limits the search to the requested strategies and to the actor in actorId, and returns one ranked list of memories. You can page through only a limited number of results. A request past that limit fails with ValidationException (reason invalidNextToken), and the message gives the limit.
Memories past their expiry (set from the space's memoryExpiryDays when each memory is written) are left out of the results. Only current memories are returned: a memory that consolidation has superseded (an older version of a fact that a newer memory replaced) is left out.
If the results are larger than 5 MiB, the request fails with ValidationException (reason queryBodyTooLarge). Lower maxResults.
If the request would exceed the service's rate for embedding requests, it fails with ThrottlingException. Retry with exponential backoff.
If the space uses a customer managed AWS KMS key, the call can also fail because of the key. It fails with AccessDeniedException if you aren't allowed to use the key, and with ThrottlingException if AWS KMS throttles the request. It fails with ValidationException if the key is disabled, pending deletion, or deleted.
Parameters:
-
space_id(SpaceId) –The space to search. Use
actorIdto narrow the search within it. -
memory_strategies(Optional[StrategySelectorList], default:None) –The strategies to search, as a list of selectors. Each selector names a memory type and, optionally, specific strategy names of that type. A space can hold several strategies of the same type. A selector without
memoryStrategyNamessearches every strategy of its type, and omittingmemoryStrategiessearches every strategy in the space. A name that is not a declared strategy of that type fails withValidationException. -
actor_id(ActorId) –The actor whose memories to search (exact match). Required: every search covers exactly one actor, and a memory stored without an actor is never returned. This is the only way to filter by actor: a query that references
system_metadata.actor_idfails withValidationException(reasonnonFilterableField). -
query(SearchQuery) –The query: a subset of the OpenSearch Query DSL (see
SearchQuery). You can't use the actor and session fieldssystem_metadata.actor_idandsystem_metadata.session_idhere. Use the top-levelactorIdto filter by actor. Searching memories doesn't filter by session. -
sort(Optional[SearchSort], default:None) –The sort order (see
SearchSort). Omit to return the most relevant memories first. -
max_results(Optional[MaxResults], default:None) –The maximum number of memories to return, from 1 to 100. The default is 20.
-
next_token(Optional[PaginationToken], default:None) –The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.
Raises:
-
AccessDeniedException–You don't have sufficient access to perform this operation. To use this operation, you must have AWS Identity and Access Management (IAM) permissions for the operation, and on the resource it acts on. If the space uses a customer managed AWS Key Management Service (AWS KMS) key, you must also have permission to use the key.
-
InternalServerException–The service couldn't process the request because of an internal error. Retry the request.
-
ResourceNotFoundException–The specified resource doesn't exist. Check the IDs in the request.
-
ThrottlingException–The service throttled the request. Retry the request with exponential backoff.
-
ValidationException–The request isn't valid. The
reason,message, andfieldListmembers describe the problem. Fix the request, and then try again. -
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_opensearchmemory/_services/async_open_search_memory.py
1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 | |