SearchImageByText - 根据文本查询图片

更新时间:
复制 MD 格式

本文为您介绍SearchImageByText的语法及示例,用于根据文字查询图像搜索实例中的图片信息。

接口说明

使用说明

本接口用于根据文字查询图像搜索实例中的图片信息。只有服务类型为商品多模态搜索才能使用。

说明

如需了解更多产品详情和获取技术支持,请单击在线咨询或通过钉钉群(35035130)联系我们。

QPS 限制

查询操作默认的最大访问频率可在控制台中查看,为您购买时所选择的访问频次(QPS),当前支持 1QPS、5QPS、10QPS。

SDK 版本说明

图像 SDK 版本升级到 V3.1.1,可使用“多主体识别”、“相似性分数”功能。请参见Java SDK。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。

  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。

  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:

    • 对于必选的资源类型,用前面加 * 表示。

    • 对于不支持资源级授权的操作,用全部资源表示。

  • 条件关键字:是指云产品自身定义的条件关键字。

  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。

操作

访问级别

资源类型

条件关键字

关联操作

imagesearch:SearchImageByText

get

*全部资源

*

无 无

请求参数

名称

类型

必填

描述

示例值

InstanceName

string

是

图搜实例名称。最多支持 20 个字符。 如果已经购买图搜实例可登录图像搜索管控台查看。 如果没有购买图搜实例可参考开通服务和创建实例。

说明

这里的实例名称并非实例 ID,使用时请区分。

demoinstance1

Num

integer

否

返回结果的数目。取值范围:1~100。默认值为 10。

10

Start

integer

否

返回结果的起始位置。取值范围:0~499。默认值为 0。

0

Filter

string

否

过滤条件。int_attr 支持的操作符有 in、not in、大于号(>)、大于等于号(>=)、小于号(<)、小于等于号(<=)、等于号(=)。str_attr 支持的操作符有 in、not in、等于号(=)和不等号(!=),多个条件之间支持 AND 和 OR 进行连接。 例如:

  • int_attr >= 100。

  • str_attr != "value1"。

  • int_attr = 1000 AND str_attr = "value1"。

说明

最多支持 4096 个字符。

int_attr=1000 AND str_attr="value1"

DistinctProductId

boolean

否

如果为 true 则检索时根据 ProductId 字段进行去重复数据。

false

Text

string

是

搜索图片的描述文本,支持中英文。

说明

最多支持 512 个字符。

xxxx

ScoreThreshold

string

否

填写相似度分数阈值后,只返回图片相似度分数大于等于阈值的图片信息。阈值范围 0.00-1.00,最大支持 2 位小数,默认为 0.00 。

0.50

返回参数

名称

类型

描述

示例值

object

返回结果。

Msg

string

错误信息。

success

Head

object

搜索结果概述信息。

DocsFound

integer

返回结果数目。

10

DocsReturn

integer

实例中命中结果数目。

10000

SearchTime

integer

搜索耗时,单位毫秒。

95

RequestId

string

请求 ID。

B3137727-7D6E-488C-BA21-0E034C38A879

Auctions

array<object>

所有返回的商品描述信息。

object

所有返回的商品描述信息。

ProductId

string

商品 ID。

2092061_1

PicName

string

图片名称。

2092061_1.jpg

CategoryId

integer

图片类目。

8888888

CustomContent

string

用户自定义的内容。

zidingyi

Score

number

图片相似打分。取值范围:0~1。

说明

需要版本升级至 V3.1.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:成功。

  • 非 0:失败。

0

PicInfo

object

所有的类目信息

AllCategories

array<object>

系统支持的所有类目信息。

object

系统支持的所有类目信息。

Name

string

类目名称。

other

Id

integer

类目 ID。

88888888

Success

boolean

请求是否成功。

true

AccessDeniedDetail

object

鉴权返回集合。

AuthAction

string

鉴权请求 Action。

xxx

AuthPrincipalDisplayName

string

鉴权主体信息。

111

AuthPrincipalOwnerId

string

鉴权主体的主账号 ID。

222

AuthPrincipalType

string

鉴权主体类型。

SubUser

EncodedDiagnosticMessage

string

加密后的完整诊断信息。

xxxxxx

NoPermissionType

string

ImplicitDeny:未命中任何策略。 ExplicitDeny:明确命中 Deny 策略。

ImplicitDeny

PolicyType

string

引起无权限的策略类型。

PauseNotify

示例

正常返回示例

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,
  "AccessDeniedDetail": {
    "AuthAction": "xxx",
    "AuthPrincipalDisplayName": "111",
    "AuthPrincipalOwnerId": "222",
    "AuthPrincipalType": "SubUser",
    "EncodedDiagnosticMessage": "xxxxxx",
    "NoPermissionType": "ImplicitDeny",
    "PolicyType": "PauseNotify"
  }
}

错误码

HTTP status code

错误码

错误信息

描述

400 BadRequest The request has invalid parameters. 无效的参数
400 InstanceStatusError Your instance is unavailable.
400 TimeoutForTransferImage Timeout after 5 seconds waiting for images transfer to complete.
400 InvalidInstance The specified instance name is invalid. 实例名错误
400 NoCaretSeperator The body content is missing the ^ separator. 请求body缺少特定符号
400 EmptyMeta The body content has an empty meta field. 请求body含有空的字段
400 InvalidMetaItem The meta field is invalid. 无效的元信息字段
400 NoPicList The body content is missing the pic_list parameter. 未指定pic_list字段
400 InvalidPicList The specified pic_list parameter is invalid. 无效的pic_list字段
400 NoSpecifiedPic he content of an image is not specified in the HTTP POST body.
400 NoSpecifiedSearchPic The search image is not specified.
400 OverflowMaxResultNum The specified number of total results exceeds the maximum of 500. 超过了最大的返回结果限制数500
400 OverflowMaxReturnNum The specified number of results for each request exceeds the maximum of 100. 单次返回数超过限制值100
400 InvalidStartParameter The specified parameter start is inavlid.
400 InvalidNumParameter The specified parameter num is invalid. 无效的字段num
400 NoSpecifiedAddPic The image to insert is not specified.
400 NoSpecifiedItemId The item_id parameter is not specified.
400 InvalidIntAttr The specified int_attr field is invalid. 无效的int过滤字段
400 InvalidFilterClause The specified filtering condition is invalid. 无效的过滤条件
400 InstanceOverQuota The number of items exceeds the limit. 实例的图片数量超过限制值
400 IncorrectOrientation The image contains incorrect rotation flags in the meta data. 图片包含不支持的旋转参数
400 UnsupportedPicPixels The specified pixels is not supported. 图片像素值不支持
400 SearchTimeout The request is timed out.
400 PicNotExist The search picture does not exist.
400 NoSpecifiedProductId The parameter ProductId no specified.
400 NoSpecifiedPicName The parameter PicName no specified.
400 NoSpecifiedPicContent The parameter PicContent no specified.
400 InvalidType The specified parameter Type is not valid.
400 InvalidProductId The specified parameter ProductId is not valid.
400 InvalidPicName The specified parameter PicName is not valid.
400 InvalidStrAttr The specified parameter StrAttr is not valid. 无效StrAttr
400 InvalidCustomContent The specified parameter CustomContent is not valid.
400 InvalidPicContent The specified parameter PicContent length greater than 4 * 1024 * 1024.
400 InvalidPicUrl The search picture does not exist at the specific url.
400 InvalidInstanceName The parameter instanceName is not specified.
400 InvalidRequestId The parameter requestId is not specified.
400 InvalidRequestIdTooLarge The parameter requestId is too large.
400 InvalidRegion The specific region is illegal
400 InvalidIntAttr4 The specified parameter IntAttr4 is not valid. 无效IntAttr4
400 InvalidIntAttr3 The specified parameter IntAttr3 is not valid. 无效IntAttr3
400 InvalidIntAttr2 The specified parameter IntAttr2 is not valid. 无效IntAttr2
400 InvalidStrAttr4 The specified parameter StrAttr4 is not valid. 无效StrAttr4
400 InvalidStrAttr3 The specified parameter StrAttr3 is not valid. 无效StrAttr3
400 InvalidStrAttr2 The specified parameter StrAttr2 is not valid. 无效StrAttr2
400 InvalidText The specified parameter Text is not valid. 描述信息Text不能为null
400 InvalidTextLength Invalid text clause. text字段长度必须在512内。
400 UnsupportedOperationType The specified action is not supported. 内部错误:不支持的action
400 UnsupportedInstanceType The instance type is not supported. 内部错误:不支持的实例类型
500 UnknownException An internal server error occurred. 未知异常
500 NetworkException A network error occurred. 内部错误:请求网络异常
500 RequestTimeout ​The request is timeout.
500 ExtractFeatureTimeout The request was timed out while extracting features.
500 AccessEngineFailed An error occurred while accessing the search engine.
500 InternalOssError An internal OAS error occurred. 内部错误:请求内部算法错误
500 InternalSwiftError An internal SWIFT error occurred. 内部错误:请求内部消息队列错误
500 InternalTableStoreError An internal Table Store error occurred. 内部错误:请求特征存储错误
500 ConnectionDVException Failed to obtain collection. internalError
403 NoPermission You are not authorized to perform this operation. 未授权的行为
403 DeniedRequest Your request was denied due to instance flow control. 请求被限流

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情。