本文为您介绍SearchImageByText的语法及示例,用于根据文字查询图像搜索实例中的图片信息。
使用说明
本接口用于根据文字查询图像搜索实例中的图片信息。只有服务类型为商品多模态搜索才能使用。
QPS限制
查询操作默认的最大访问频率可在控制台中查看,为您购买时所选择的访问频次(QPS),当前支持1QPS、5QPS、10QPS。
SDK版本说明
图像SDK版本升级到V3.1.1,可使用“多主体识别”、“相似性分数”功能。请参见Java SDK。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 |
类型 |
是否必选 |
示例值 |
描述 |
Action | String | 是 | SearchImageByText | 系统规定参数。取值:SearchImageByText。 |
InstanceName | String | 是 | demoinstance1 | 图搜实例名称。最多支持20个字符。 如果已经购买图搜实例可登录图像搜索管控台查看。 说明 这里的实例名称并非实例ID,使用时请区分。 |
Num | Integer | 否 | 10 | 返回结果的数目。取值范围:1~100。默认值为10。 |
Start | Integer | 否 | 0 | 返回结果的起始位置。取值范围:0~499。默认值为0。 |
Filter | String | 否 | int_attr=1000 AND str_attr="value1" | 过滤条件。int_attr支持的操作符有大于号(>)、大于等于号(>=)、小于号(<)、小于等于号(<=)、等于号(=)。str_attr支持的操作符有等于号(=)和不等号(!=),多个条件之间支持AND和OR进行连接。 例如:
说明 最多支持4096个字符。 |
DistinctProductId | Boolean | 否 | false | 如果为true则检索时根据ProductId字段进行去重复数据。 |
Text | String | 是 | xxxx | 搜索图片的描述文本,支持中英文。 说明 最多支持512个字符。 |
返回数据
名称 |
类型 |
示例值 |
描述 |
Msg | String | success | 错误信息。 |
Head | Object | 搜索结果概述信息。 |
|
DocsFound | Integer | 10 | 返回结果数目。 |
DocsReturn | Integer | 10000 | 实例中命中结果数目。 |
SearchTime | Integer | 95 | 搜索耗时,单位毫秒。 |
RequestId | String | B3137727-7D6E-488C-BA21-0E034C38A879 | 请求ID。 |
Auctions | Array of Auction | 所有返回的商品描述信息。 |
|
ProductId | String | 2092061_1 | 商品ID。 |
PicName | String | 2092061_1.jpg | 图片名称。 |
CategoryId | Integer | 8888888 | 图片类目。 |
CustomContent | String | zidingyi | 用户自定义的内容。 |
Score | Float | 1 | 图片相似打分。取值范围:0~1。 说明 需要版本升级至V3.1.1方可使用。 |
IntAttr | Integer | 2 | 整数类型属性。 |
IntAttr2 | Integer | 2 | 整数类型属性。 |
StrAttr2 | String | xxxx | 字符串类型属性。 |
StrAttr | String | xxxx | 字符串类型属性。 |
StrAttr3 | String | xxxx | 字符串类型属性。 |
StrAttr4 | String | xxxx | 字符串类型属性。 |
IntAttr3 | Integer | 2 | 整数类型属性。 |
IntAttr4 | Integer | 2 | 整数类型属性。 |
Code | Integer | 0 | 错误码。
|
PicInfo | Object | 所有的类目信息 |
|
AllCategories | Array of Category | 系统支持的所有类目信息。 |
|
Name | String | other | 类目名称。 |
Id | Integer | 88888888 | 类目ID。 |
Success | Boolean | true | 请求是否成功。 |
AccessDeniedDetail | Object | 鉴权返回集合。 |
|
AuthAction | String | xxx | 鉴权请求Action。 |
AuthPrincipalDisplayName | String | 111 | 鉴权主体信息。 |
AuthPrincipalOwnerId | String | 222 | 鉴权主体的主账号ID。 |
AuthPrincipalType | String | SubUser | 鉴权主体类型。 |
EncodedDiagnosticMessage | String | xxxxxx | 加密后的完整诊断信息。 |
NoPermissionType | String | ImplicitDeny | ImplicitDeny:未命中任何策略。 ExplicitDeny:明确命中Deny策略。 |
PolicyType | String | PauseNotify | 引起无权限的策略类型。 |
示例
请求示例
http(s)://[Endpoint]/?Action=SearchImageByText
&InstanceName=demoinstance1
&Num=10
&Start=0
&Filter=int_attr=1000 AND str_attr="value1"
&DistinctProductId=false
&Text=xxxx
&公共请求参数
正常返回示例
XML
格式
HTTP/1.1 200 OK
Content-Type:application/xml
<SearchImageByTextResponse>
<Msg>success</Msg>
<Head>
<DocsFound>10</DocsFound>
<DocsReturn>10000</DocsReturn>
<SearchTime>95</SearchTime>
</Head>
<RequestId>B3137727-7D6E-488C-BA21-0E034C38A879</RequestId>
<Auctions>
<ProductId>2092061_1</ProductId>
<PicName>2092061_1.jpg</PicName>
<CategoryId>8888888</CategoryId>
<CustomContent>zidingyi</CustomContent>
<Score>1</Score>
<IntAttr>2</IntAttr>
<IntAttr2>2</IntAttr2>
<StrAttr2>xxxx</StrAttr2>
<StrAttr>xxxx</StrAttr>
<StrAttr3>xxxx</StrAttr3>
<StrAttr4>xxxx</StrAttr4>
<IntAttr3>2</IntAttr3>
<IntAttr4>2</IntAttr4>
</Auctions>
<Code>0</Code>
<PicInfo>
<AllCategories>
<Name>other</Name>
<Id>88888888</Id>
</AllCategories>
</PicInfo>
<Success>true</Success>
</SearchImageByTextResponse>
JSON
格式
HTTP/1.1 200 OK
Content-Type:application/json
{
"Msg" : "success",
"Head" : {
"DocsFound" : 10,
"DocsReturn" : 10000,
"SearchTime" : 95
},
"RequestId" : "B3137727-7D6E-488C-BA21-0E034C38A879",
"Auctions" : [ {
"ProductId" : "2092061_1",
"PicName" : "2092061_1.jpg",
"CategoryId" : 8888888,
"CustomContent" : "zidingyi",
"Score" : 1,
"IntAttr" : 2,
"IntAttr2" : 2,
"StrAttr2" : "xxxx",
"StrAttr" : "xxxx",
"StrAttr3" : "xxxx",
"StrAttr4" : "xxxx",
"IntAttr3" : 2,
"IntAttr4" : 2
} ],
"Code" : 0,
"PicInfo" : {
"AllCategories" : [ {
"Name" : "other",
"Id" : 88888888
} ]
},
"Success" : true
}