Introduction The search service is a global and shared resource properties repository that is integrated in the IBM Cloud® platform. It's used for storing and searching cloud resource attributes. It categorizes and classifies resources. A resource is controlled and owned by resource providers within the IBM Cloud platform, such as IBM Cloud Kubernetes Service, or Resource Controller. Resources are uniquely identified by a Cloud Resource Naming identifier CRN. The properties of a resource include tags and system properties. Both properties are defined within an IBM Cloud billing account, and span across many regions. The search service can list, query, and retrieve information about IBM Cloud resources in the user IBM Cloud billing account, including IAM Access Groups AG and IAM Service IDs. It cannot retrieve resources that are: - Users - IAM API keys - IAM Trusted profiles - Context Based Restrictions CBR Zones and Rules - Support Cases - Billing data - Cost estimations. The search service cannot retrieve Deployable Architectures DA and related information, documentation, or release notes. SDKs for Java, Node, Python, and Go are available to make it easier to programmatically access the API from your code. The client libraries that are provided by the SDKs implement best practices for using the API and reduce the amount of code that you need to write. The tab for each language includes code examples that demonstrate how to use the client libraries. For more information about using the SDKs, see the IBM Cloud SDK Common projecthttps://github.com/IBM/ibm-cloud-sdk-common on GitHub. To filter search results, you can apply query strings following the Lucene query syntax: - Basic Term: A single word is a term, and it searches for that word in all the resource attributes. Example: database searches for the word database in all the resource attributes. - Phrase: A group of words surrounded by double quotes " " forms a phrase query, and it searches for all the words in the same order. Example: "My resource" searches for the exact phrase in all the resource attributes. - Field: Specify a resource attribute for a term by prefixing it with the attribute name followed by a colon :. Example: name:my-resource searches for resources whose attribute name is my-resource. - Boolean Operators: AND finds resources containing both terms, OR finds resources containing either term, NOT excludes resources containing the term. Boolean operators must be capitalized. Example: my-resource AND database searches for words my-resource and database in all the resource attributes. - Wildcards: matches any character sequence including none, and ? matches a single character. Example: my-res finds my-resource, my-resources, etc. - Special characters: Enclose in double-quotes terms containing special characters: + & | { } ^ : \ / as they are reserved in Lucene query syntax e.g. CRNs, type-4 GUIDs. Example: name:"FancyResource&Co.". - Ranges: Search for terms within a range. Can be numeric or alphabetical. Inclusive range: start TO end, exclusive range: {start TO end}. Example: creationdate:2021-01-01 TO 2021-12-31 finds resources whose creationdate is in the range. - Grouping: Group queries with parentheses to control operator precedence. Example: database OR containers-kubernetes AND name:my-resource find database or container-kubernetes resources named my-resource. The most commonly used resource attributes or fields that you can query and retrieve are: - accesstags: The list of access management tags attached to the resource. - accountid: The billing account ID of the resource. - catalogtags: The list of tags determining the resource categories. - creationdate: The date on which the resource was created in ISO format "YYYY-MM-DDTHH:mm:ss.SSSZ". - crn: The Cloud Resource Name in the format: "crn:version:cname:ctype:service-name:location:scope:service-instance:resource-type:resource". - modificationdate: The date on which the resource was last updated in ISO format "YYYY-MM-DDTHH:mm:ss.SSSZ". - name: The user-provided resource name. - region: The IBM Cloud location of the resource. - resourcegroupid: The unique identifier of the resource group into which the resource is provisioned. - serviceinstance: The unique identifier of the service instance. - resourceid: The unique identifier of the resource provisioned by a service instance. - servicename: The name of the service as it appears in the Name column of the output of ibmcloud catalog service-marketplace. - servicetags: The list of service tags attached to the resource. - tags: The list of user tags attached to the resource. - type: The type of the resource. Using the /resources/search API you can retrieve or list IBM Cloud resources and services using a variety of filters. Only resources that belong to the account ID and that are accessible by the client are returned. Hereafter only some of the use cases that you can accomplish by building the right Lucene query. To check if your backup policies are correctly configured you can use the query: servicename:is AND type:backup-policy which returns the backup policies that you are entitled to view. You can verify when a PostgreSQL database named mydb was created and updated by using the query servicename:compose-for-postgresql AND name:mydb and check the creationdate and modificationdate fields. You can list resources whose name starts with either climatechange or globalwarming by using the query name:climatechange OR globalwarming. You can retrieve resources by date. For example, those updated between 2020 and 2022 using the query modificationdate:2020 TO 2022. You can use the notation now-X TO now for time relative queries: - For "last X years" use the range now-Xy TO now - For "last X months" use the range now-XM TO now - For "last X weeks" use the range now-Xw TO now - For "last X days" use the range now-Xd TO now - For "last X hours" use the range now-Xh TO now - For "last X minutes" use the range now-Xm TO now - For "last X seconds" use the range now-Xs TO now For example, the query creationdate:now-1w TO now returns the resources created in the last week. Another interesting set of use cases is querying resources in your account by category: e.g., compute, network, storage, databases, security, devops. Suppose you want to know if there are databases in your account. You can list them using the query: catalogtags:databases. Similarly, if you want to know if there are specific services provisioned in your account you can use a query like: servicename:databases-for-elasticsearch OR cloudantnosqldb which returns instances of Elasticsearch or Cloudant databases that you are entitled to view. Sometimes, you need to obtain the CRN of a resource given its name, or vice versa: the name of a resource given its CRN. To do so you can use the queries: name:your-resource-name and crn:”your-resource-crn” respectively. You can use the serviceinstance:your-service-instance-id or resourceid:your-resource-id as an alternative to the CRN to retrieve the name of a resource. Finally, you can filter resources by tags. Suppose that you are interested in resources tagged as dev, test, and production. You can use the queries: tags:dev, tags:test, and tags:production respectively. What if you are interested in resources provisioned with an enterprise project configuration? All resources provisioned with a project do have service tags, which can be used to get them. For example, the query: servicetags:”project::configid:1e3bf974-0f34-4a96-960b-15823558f952” AND “project::projectid:efd46015-1902-4465-99a4-a0e12fba5759” returns all the resources provisioned with the specified projectid and configid. Installing the Java SDK Maven xml Method Path Summary POST /v2/resources/search Find instances of resources (v2) POST /v3/resources/search Find instances of resources (v3)