content: package sample;
  
  import com.aliyun.oss.ClientException;
  import com.aliyun.oss.OSS;
  import com.aliyun.oss.OSSClientBuilder;
  import com.aliyun.oss.OSSException;
  import com.aliyun.oss.model.*;
  import java.util.ArrayList;
  import java.util.List;
  
  public class BucketMetaQuerySample {
  
      private static String endpoint = "*** Provide OSS endpoint ***";
      private static String accessKeyId = "*** Provide your AccessKeyId ***";
      private static String accessKeySecret = "*** Provide your AccessKeySecret ***";
      private static String bucketName = "*** Provide bucket name ***";
  
      public static void main(String[] args) {
  
          OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
  
          try {
              int maxResults = 20;
              List<String> mediaTypes = new ArrayList<String>();
              mediaTypes.add("image");
              String query = "Snow";
              String simpleQuery = "{\"Operation\":\"gt\", \"Field\": \"Size\", \"Value\": \"30\"}";
              String sort = "Size";
              DoMetaQueryRequest doMetaQueryRequest = new DoMetaQueryRequest(bucketName, maxResults, query, sort, MetaQueryMode.SEMANTIC, mediaTypes, simpleQuery);
              DoMetaQueryResult doMetaQueryResult = ossClient.doMetaQuery(doMetaQueryRequest);
          } catch (OSSException oe) {
              System.out.println("Error Message: " + oe.getErrorMessage());
              System.out.println("Error Code:       " + oe.getErrorCode());
              System.out.println("Request ID:      " + oe.getRequestId());
              System.out.println("Host ID:           " + oe.getHostId());
          } catch (ClientException ce) {
              System.out.println("Error Message: " + ce.getMessage());
          } finally {
              if(ossClient != null){
                  ossClient.shutdown();
              }
          }
      }
  }
  