Restriction
If there is a facet property in search config, its mapped fields should always match those in search criteria property. These fields should be the existing data schema with the same type, granularity, and search strategy.
Create a search config
REST
To create a SearchConfig resource, send a POST request by using the
projects.locations.corpora.searchConfigs.create
method.
Here is the example of how to create a search config with customized search criteria.
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_IDsuch aseurope-west4-. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Agent Platform Vision. For example:
us-central1,europe-west4. See available regions. - CORPUS_ID: The ID of your target corpus.
- SEARCHCONFIG: The name of your target
SearchConfig. - The
SearchConfigin this example isperson.
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/searchConfigs?search_config_id=person
Request JSON body:
{
"search_criteria_property": {
"mapped_fields": "player",
"mapped_fields": "coach",
"mapped_fields": "cheerleader",
}
}
To send your request, choose one of these options:
curl
Save the request body in a file named request.json,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/searchConfigs?search_config_id=person"
PowerShell
Save the request body in a file named request.json,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/searchConfigs?search_config_id=person" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{
"name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/searchConfigs/person",
"searchCriteriaProperty":
{
"mappedFields": [
"player",
"coach",
"cheerleader"
]
}
}
Update a search config
REST
To update a SearchConfig resource, send a POST request by using the
projects.locations.corpora.searchConfigs.patch
method.
Here is the example of how to create a search config with customized search criteria.
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_IDsuch aseurope-west4-. See more about regionalized endpoints. - PROJECT: Your Google Cloud project ID or project number.
- LOCATION_ID: The region where you are using
Agent Platform Vision. For example:
us-central1,europe-west4. See available regions. - CORPUS_ID: The ID of your target corpus.
- SEARCHCONFIG_ID: The ID of your target
SearchConfig. "mappedFields": One or more existing user-given annotation keys.
HTTP method and URL:
PATCH https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/searchConfigs/SEARCHCONFIG_ID
Request JSON body:
{
"name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/searchConfigs/SEARCHCONFIG_ID1",
"searchCriteriaProperty": {
"mappedFields": "dataschema2"
}
}
To send your request, choose one of these options:
curl
Save the request body in a file named request.json,
and execute the following command:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/searchConfigs/SEARCHCONFIG_ID"
PowerShell
Save the request body in a file named request.json,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/searchConfigs/SEARCHCONFIG_ID" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{
"name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/searchConfigs/SEARCHCONFIG_ID1",
"searchCriteriaProperty": {
"mappedFields": [
"dataschema2"
]
}
}
Get a search config
The following example shows you how to retrieve an existing SearchConfig that
makes it easier to search for people in warehouse-stored data.
REST
To get details about a SearchConfig, send a GET request by using the
projects.locations.corpora.searchConfigs.get
method.
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_IDsuch aseurope-west4-. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Agent Platform Vision. For example:
us-central1,europe-west4. See available regions. - CORPUS_ID: The ID of your target corpus.
- SEARCHCONFIG: The name of your target
SearchConfig. - The
SearchConfigin this example isperson.
HTTP method and URL:
GET https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/searchConfigs/SEARCHCONFIG
To send your request, choose one of these options: