Class GeminiCorporaQueryRequest
- Namespace
- Uralstech.UGemini.CorporaAPI
Performs semantic search over a Corpus or Document. Response type is GeminiCorporaQueryResponse.
public class GeminiCorporaQueryRequest : IGeminiPostRequest, IGeminiRequest
- Inheritance
-
objectGeminiCorporaQueryRequest
- Implements
- Extension Methods
Remarks
Only available in the beta API.
Constructors
GeminiCorporaQueryRequest(IGeminiCorpusResourceId, bool)
Creates a new GeminiCorporaQueryRequest.
public GeminiCorporaQueryRequest(IGeminiCorpusResourceId resourceId, bool useBetaApi = true)
Parameters
resourceIdIGeminiCorpusResourceIdThe resource ID of the Corpus or Document to Query.
useBetaApiboolShould the request use the Beta API?
Remarks
Only available in the beta API.
Fields
ApiVersion
The API version to use.
public string ApiVersion
Field Value
- string
MetadataFilters
Filter for Chunk and Document metadata.
public GeminiMetadataFilter[] MetadataFilters
Field Value
Remarks
Each GeminiMetadataFilter object should correspond to a unique key. Multiple MetadataFilter objects are joined by logical "AND"s.
Example query at document level:
(year >= 2020 OR year < 2010) AND (genre = drama OR genre = action)
Note: Document-level filtering is not supported for query requests on Documents because a Document name is already specified.
MetadataFilter object list:
MetadataFilters = [{Key = "document.custom_metadata.year", Conditions = [{NumericValue = 2020, Operation = GreaterThanOrEqual}, {NumericValue = 2010, Operation = LessThan
}]}, {Key = "document.custom_metadata.year", Conditions = [{NumericValue = 2020, Operation = GreaterThanOrEqual}, {NumericValue = 2010, Operation = LessThan}]}, {Key =
"document.custom_metadata.genre", Conditions = [{StringValue = "drama", Operation = Equal}, {StringValue = "action", Operation = Equal}]}]
Example query at chunk level for a numeric range of values:
(year > 2015 AND year <= 2020)
MetadataFilter object list:
metadataFilters = [{Key = "chunk.custom_metadata.year", Conditions = [{NumericValue = 2015, Operation = GreaterThan}]}, {Key = "chunk.custom_metadata.year"
Conditions = [{NumericValue = 2020, Operation = LessThanOrEqual}]}]
Note: "AND"s for the same Key are only supported for numeric values. String values only support "OR"s for the same Key.
Query
Query string to perform semantic search.
public string Query
Field Value
- string
ResourceId
The resource ID of the Corpus or Document to query.
public IGeminiCorpusResourceId ResourceId
Field Value
ResultsCount
The maximum number of Chunks to return. The service may return fewer Chunks.
public int ResultsCount
Field Value
- int
Remarks
If unspecified, at most 10 Chunks will be returned. The maximum specified result count is 100.
Properties
AuthMethod
The preferred authentication method.
public GeminiAuthMethod AuthMethod { get; set; }
Property Value
ContentType
The MIME type of the request content.
public string ContentType { get; }
Property Value
- string
OAuthAccessToken
The OAuth access token to authenticate the request, if using OAuthAccessToken as AuthMethod.
public string OAuthAccessToken { get; set; }
Property Value
- string
Methods
GetEndpointUri(GeminiRequestMetadata)
Gets the URI to the API endpoint.
public string GetEndpointUri(GeminiRequestMetadata metadata)
Parameters
metadataGeminiRequestMetadataThe metadata of the request to be carried out on the URI.
Returns
- string
The URI.
GetUtf8EncodedData()
Converts the request object to a UTF-8 encoded string.
public string GetUtf8EncodedData()
Returns
- string
The string data.