All Products
Document Center


Last Updated: Jul 07, 2020


This feature allows you to set filters when searching images. For example, you can set a filter to return only images with an owner ID of 1000 or with the company name of “alibaba”.

Supported version

The filtering feature is only available for instances created after March 27, 2018. To upgrade instances with an earlier version, submit a ticket.

How to use filtering

  • This feature currently supports filtering by the int_attr and str_attr fields. The int_attr field is a built-in integer attribute, and the str_attr field is a built-in string attribute.

  • When you insert an image, you can specify the the int_attr and str_attr fields.

    • The following notation is an example that you can use when uploading an image in OSS Import mode.
      1. {"OperationType":"ADD","ProductId":"1000", "CategoryId":0, "IntAttr":0, "StrAttr":"value1", "CustomContent":"k1:v1,k2:v2,k3:v3", "PicName":"girl_cloth1.jpg"}
    • Alternatively, you can use the latest version (1.0.3 or later) of the SDK to set these fields. Specifically, you can use the setIntAttr and setStrAttr methods on the AddItemRequest object to set the int_attr and str_attr fields respectively.
  • You can specify a filter for your search. The int_attr field supports the following operators: >、>=、<、<=、=. The str_attr field supports the following operators: =、!=. You can use the AND and OR operators to combine multiple filtering conditions.

    1. int_attr>=100
    2. str_attr!="value1"
    3. int_attr=1000 AND str_attr="value1"
    • When you use the API to perform a search, you can set the filter parameter to this value.

    • When you use the SDK to perform a search, you can call the setFilterClause function on the SearchItemRequest object.

Items per category

When you use this feature, make sure that each category contains less than 2 million images. If a category contains more than 2 million images, and if you have not performed an OSS Import and Rebuild operation, search requests can also be handled. However, search requests may be timed out.