Image Retrieval
Search for similar images in an image gallery by image (Base64 input) or by text description, with optional tag-based filtering.
API Overview
Note: All APIs use the prefix /api/v1/operators/image-search.
|
API Name |
Method |
Path |
|
Search by image in a specified image gallery |
POST |
|
|
Text-to-image search in a specified image gallery |
POST |
|
1. Search by Image
Request method: POST
Request path: /api/v1/operators/image-search/search/by-image
Description: Retrieve visually similar images from a specified image gallery using a Base64-encoded image as input.
Request Parameters
|
Parameter |
Type |
Required |
Default |
Description |
|
|
string |
Yes |
None |
Target image gallery name. |
|
|
string |
Yes |
None |
Base64-encoded string of the query image. |
|
|
int |
No |
|
Maximum number of results to return. |
|
|
list [object] |
No |
None |
Tag-based filter conditions. Uses the tag_filter filtering syntax. |
|
|
bool |
No |
|
Include Base64-encoded image content in the response. Set to |
Request example
curl -X POST 'http://localhost:8000/api/v1/operators/image-search/search/by-image' \
-H 'Content-Type: application/json' \
-d '{
"library_name": "shop_a_tops",
"image_base64": "/9j/4AAQSkZJRgABAQAAAQABAAD...",
"top_k": 5,
"tag_filter": [
{"field": "color", "op": "=", "value": "red"},
{"field": "season", "op": "=", "value": "summer"}
]
}'
Response
HTTP status codes
|
Status Code |
Description |
|
200 |
Search succeeded (results may be an empty list). |
|
400 |
Invalid request parameters. |
|
404 |
Image gallery does not exist. |
|
500 |
Internal server error. |
data field
|
Field Name |
Type |
Description |
|
|
list[object] |
Search results sorted by similarity score (descending). Empty list if no matches. |
|
|
string |
Unique image identifier. |
|
|
string |
Image resource identifier (value provided at import). |
|
|
string / null |
Base64-encoded image content. |
|
|
float |
Similarity score (0 to 1). Higher values indicate greater similarity. |
|
|
object |
Custom tags associated with the image. |
Response example (with results)
{
"status": "SUCCESS",
"message": null,
"data": {
"results": [
{
"image_id": "img001",
"image_uri": "https://example.com/tops/img001.jpg",
"image_base64": "/9j/4AAQSkZJRgABAQAAAQABAAD...",
"score": 0.962,
"tags": {
"color": "red",
"season": "summer"
}
},
{
"image_id": "img002",
"image_uri": "https://example.com/tops/img002.jpg",
"image_base64": "/9j/4AAQSkZJRgABAQAAAQABAAD...",
"score": 0.891,
"tags": {
"color": "red",
"season": "summer"
}
}
]
}
}
Response example (no results)
{
"status": "SUCCESS",
"message": null,
"data": {
"results": []
}
}
2. Text-to-Image Search
Request method: POST
Request path: /api/v1/operators/image-search/search/by-text
Description: Retrieve semantically matching images from a specified image gallery using a text description as input.
Supports multilingual input. In Chinese mainland deployments, the server translates input text into Chinese before searching.
Note: Only available for image galleries in general_search mode. Other modes return HTTP 400.
Request Parameters
|
Parameter |
Type |
Required |
Default |
Description |
|
|
string |
Yes |
None |
Target image gallery name. Must be in |
|
|
string |
Yes |
None |
Search query text, such as |
|
|
int |
No |
|
Maximum number of results to return. |
|
|
list [object] |
No |
None |
Tag-based filter conditions. Uses the tag_filter filtering syntax. |
|
|
bool |
No |
|
Include Base64-encoded image content in the response. Set to |
Request example
curl -X POST 'http://localhost:8000/api/v1/operators/image-search/search/by-text' \
-H 'Content-Type: application/json' \
-d '{
"library_name": "general_clothing",
"query_text": "a white short-sleeve T-shirt",
"top_k": 10,
"tag_filter": [
{"field": "season", "op": "=", "value": "summer"},
{"field": "category", "op": "=", "value": "pants"}
]
}'
Response
HTTP status codes
|
Status Code |
Description |
|
200 |
Search succeeded (results may be an empty list). |
|
400 |
Invalid request parameters or unsupported gallery mode (not general_search). |
|
404 |
Image gallery does not exist. |
|
500 |
Internal server error. |
The data field structure is identical to search by image above.
Response example
{
"status": "SUCCESS",
"message": null,
"data": {
"results": [
{
"image_id": "img001",
"image_uri": "https://example.com/tops/img001.jpg",
"image_base64": "/9j/4AAQSkZJRgABAQAAAQABAAD...",
"score": 0.943,
"tags": {
"category": "pants",
"season": "summer"
}
}
]
}
}
Failure response example (HTTP 400)
{
"status": "MODE_NOT_SUPPORTED",
"message": "Image library 'shop_a_tops' is in item_search mode and does not support text-to-image search.",
"data": null
}
tag_filter Syntax
Filter search results by tags using the tag_filter parameter. tag_filter supports exact match and numeric range filtering. Multiple conditions are combined with AND logic.
Condition Object
Each condition is a JSON object:
{"field": "color", "op": "=", "value": "red"}
|
Field |
Type |
Required |
Default |
Description |
|
|
string |
Yes |
None |
Tag field name. |
|
|
string |
Yes |
None |
Comparison operator. |
|
|
string / number |
Yes |
None |
Value to match. Strings use exact match; numbers support exact match and range filtering. |
Operators
|
op |
Meaning |
Value Type |
Example |
|
|
Exact match |
string/number |
|
|
|
Greater than |
number |
|
|
|
Greater than or equal to |
number |
|
|
|
Less than |
number |
|
|
|
Less than or equal to |
number |
|
Logical Combination
tag_filter is a JSON array. All conditions are combined with AND logic — every condition must be satisfied.
Examples
Multiple conditions combined with AND
[
{"field": "color", "op": "=", "value": "red"},
{"field": "season", "op": "=", "value": "summer"}
]
Meaning: color = "red" AND season = "summer"
E-commerce scenario example (filter by category + color + price range)
[
{"field": "category", "op": "=", "value": "T-shirt"},
{"field": "color", "op": "=", "value": "white"},
{"field": "price", "op": ">=", "value": 50},
{"field": "price", "op": "<=", "value": 200}
]
Meaning: category = "T-shirt" AND color = "white" AND price >= 50 AND price <= 200