Documentation for how to call the Query APIs using the Aryn SDK
Please find the documentation for the functions that call the Query APIs using the SDK below. All parameters are optional unless specified otherwise.
Search over a docset and get back documents or elements that match your search criteria.
Parameters
docset_id
: A string specifying the id of the docset you are searching over.query
: A string that specifies what term you are searching for within the contents of your documents. The query_type parameter specified below will control exactly how this query parameter is used to search over your documents.query_type
: An enum that can be either keyword
, vector
, or lexical
:
keyword
is specified, the search call will perform a substring match and return results that contain strings that contain the query term specified.vector
is specified, the search call will internally embed the query with the embedding function associated with the docset you are querying on and perform a k-nearest neighbor search to retrieve the results.lexical
is specified, the search call will perform an exact string match and return results where the query string shows up as a standalone word.properties_filter
: A string that specifies a boolean expression. This expression specifies the condition to use when extracting documents or elements from the docset. The boolean expression is a string consisting of conditions separated by the AND/OR keywords. The following are a few examples:
k
: The number of records to return back.return_type
: An enum that an be either doc
or element
. When doc
is specified, documents that match the search criteria are retuned. When element
is specified, specific sections of the document (i.e. elements) are returned.page_token
: A string used for pagination purposes. If provided, this will indicate to the server where to begin the next set of records to return. Valid for 24 hours.Example
Return Value
A SearchResponse object which contains the following attributes:
results
: A list containing either the documents or elements that matched the search criteria.query_embedding
: If the query_type selected is ‘vector’, this field indicates the embedding vector that was used to perform the search.next_page_token
: The pagination token. If None, there are no more search results to retrieve. If not None, the caller may use this to retrieve more results for the particular search query.Exceptions
User errors:
HTTPError: Error:status_code 403
. Reason: "No Aryn API Key provided"
ARYN_API_KEY
.HTTPError: Error:status_code 403
. Reason: "Invalid Aryn API key"
ARYN_API_KEY
.HTTPError: Error:status_code 403
. Reason: "Expired Aryn API key"
HTTPError: Error:status_code 404
. Reason: "Docset not found error"
HTTPError: Error:status_code 400
. Reason: "Incorrect input"
Other errors:
HTTPError: Error:status_code 5xx
. Reason: Internal Server Error
Generate a query plan for the given query, but do not run it.
Parameters
A Query
object describing the query to build and return a LogicalPlan
for.
Example
Return Value
A LogicalPlan
object.
Exceptions
HTTPError 403
: “No Aryn API Key provided”HTTPError 403
: “Invalid Aryn API key”HTTPError 403
: “Expired Aryn API key”HTTPError 5xx
: Internal Server ErrorEdit a plan.
Parameters
Example
Return Value
A LogicalPlan
object.
Exceptions
HTTPError 403
: “No Aryn API Key provided”HTTPError 403
: “Invalid Aryn API key”HTTPError 403
: “Expired Aryn API key”HTTPError 5xx
: Internal Server ErrorRun a query either from a Query
based on a string or a Query
based on a plan.
Parameters
Example
Return Value
Either a QueryResult
or an Iterator[QueryEvent]
.
Exceptions
HTTPError 403
: “No Aryn API Key provided”HTTPError 403
: “Invalid Aryn API key”HTTPError 403
: “Expired Aryn API key”HTTPError 5xx
: Internal Server Error