Filtering Resource Search Results

Apply filters to narrow down a list of resource results according to various resource attributes.

How you filter the results from a search for resources depends on the mode you use to find the results.

Basic search mode supports different ways of filtering resource search results through the Console. You can either use the in-page search box or you can use column headings in the results list. This topic describes how to use the in-page search box to access filters, but the filters in column headings in the results list behave the same way.

Advanced query mode supports filtering and sorting resources through query language syntax. You effectively filter results by adding or removing clauses or changing the content of clauses. The only query you can perform that doesn't filter results is a query for everything. No filters for results returned by a query exist in the Console itself.

Understanding the following information can help you filter resource search results to better find what you need:
  • By default, if you have more than one string with spaces between them in a free text search or in basic search mode, the Console finds resources containing any of the search strings. Search doesn't try to find resources containing all the search strings. For more information about free text searches, see Free Text Search.
  • You can use either the in-page search box or the column headings in a list of search results to apply filters to the results. The Console reflects any changes to filters in both places.
  • Some filters include all possible attribute values by default. Namely, the compartment filter includes all compartments in the search until you specify compartments to remove from the filter. Meanwhile, other filters match no attribute values by default.
  • You can clear filters. For more information, see Clearing Resource Search Filters.
  • You can change filters. For more information, see Changing Resource Search Filters.
  • You can sort results. For more information, see Sorting Resource Search Results.
  • These steps assume that you already performed a free text search and selected the Resources category of results according to the instructions in Performing a Free Text Search.

    1. On the Resources page, click the search box, and then type or choose a resource type or resource attribute to include in the filtered search results. (Available attributes depend on the resource types in the results list.)
    2. Then, do one of the following:
      • If you selected a filter that provides predefined options, select the option from a menu or by selecting one or more check boxes.
      • If you selected a filter that requires you to specify the value of the resource attribute to compare potential search results to, click the filter box and enter an appropriate value. (Note: Filters where you can enter a custom value require that you enter at least three characters before you apply the filter.)
      • If you selected the Display name or OCID filter, you can only enter one value at a time for either filter.
      • If you selected the Tag filter, first choose the type of tag from the menu options. Then, specify whether you want to Match any value or Specify matching values. Lastly, specify the value or values that you want the filter to match.
      • If you selected a time-based filter, specify the Start Date, Start Time, End Date, and End Time.
    3. When you're ready, click Apply filter.
    4. (Optional) To add another filter, repeat the previous steps.
  • Use the oci search resource structured-search command and required parameters to apply filters when finding resources:

    oci search resource structured-search --query-text "<query_text_using_query_language_syntax>"

    For a complete list of parameters and values for CLI commands, see the CLI Command Reference. For information about the syntax for queries, see Search Language Syntax.

  • Run the SearchResources operation to use structured query language to filter resources.

    Example: Finding All Resource Attributes of a Resource-Type That Contain a Specific String

    This section describes how to use the API to query all indexed fields of a particular resource-type for matches to a specific string.

    The following query finds users with any attributes that contain "doe".

    query
     user resources
     matching
     'doe'

    When you use the SearchResources operation to issue the query, the request looks similar to the following. (This example purposefully omits the authorization header and other headers.)

    POST /20180409/resources
    Host: query.us-phoenix-1.oraclecloud.com
    <authorization and other headers>
    {
      "type": "Structured",
      "query": "query user resources matching 'doe'",
      "matchingContextType": "HIGHLIGHTS"
    }

    If the query produces results, the response lists the resources that match the resource-type and tag that you specified. The response looks similar to the following:

    {
      "items" : [ {
        "resourceType" : "User",
        "identifier" : "ocid1.user.oc1..examplea26nj4iqy2mbfauxovw5viuyblsbdn3p6cvbdmbrjtalxgjqdnemq",
        "compartmentId" : "ocid1.tenancy.oc1..exampleagkbzgg6lpzrf47xzy4rjoxg4de6nfaux2rncmjiujvy2cvbxvziq",
        "timeCreated" : "2020-12-10T14:41:02.185Z",
        "displayName" : "janedoe",
        "availabilityDomain" : "ABCd:PHX-AD-3",
        "lifecycleState" : "ACTIVE",
        "freeformTags" : { },
        "definedTags" : { },
        "systemTags" : { },
        "searchContext" : {
          "highlights" : {
            "displayName" : [ "<hl>janedoe</hl>" ],
            "name" : [ "<hl>janejdoe</hl>" ],
            "description" : [ "Jane <hl>Doe</hl> - <hl>jane.doe</hl>@example.com" ]
          }
        },
        "identityContext" : { },
        "additionalDetails" : { }
      }, {
        "resourceType" : "User",
        "identifier" : "ocid1.user.oc1..examplea27jaoic76zube2d6faux5hch5fsj36qetod474g57cvbhguoegfa",
        "compartmentId" : "ocid1.tenancy.oc1..exampleagkbzgg6lpzrf47xzy4rjoxg4de6nfaux2rncmjiujvy2cvbxvziq",
        "timeCreated" : "2022-09-22T15:14:44.285Z",
        "displayName" : "sdoerner",
        "availabilityDomain" : "ABCd:PHX-AD-3",
        "lifecycleState" : "ACTIVE",
        "freeformTags" : { },
        "definedTags" : { },
        "systemTags" : { },
        "searchContext" : {
          "highlights" : {
            "displayName" : [ "<hl>sdoerner</hl>" ],
            "name" : [ "<hl>sdoerner</hl>" ],
            "description" : [ "Scott <hl>Doerner</hl> - <hl>scott.doerner</hl>@example.com" ]
          }
        },
        "identityContext" : { },
        "additionalDetails" : { }
      }, {
        "resourceType" : "User",
        "identifier" : "ocid1.user.oc1..examplea2agbfauxqj57pwe2txjdc6mjdkcncdt5m5bmcvbbzznxzscixd7a",
        "compartmentId" : "ocid1.tenancy.oc1..exampleagkbzgg6lpzrf47xzy4rjoxg4de6nfaux2rncmjiujvy2cvbxvziq",
        "timeCreated" : "2020-09-11T22:00:26.311Z",
        "displayName" : "patdoerr",
        "availabilityDomain" : "ABCd:PHX-AD-2",
        "lifecycleState" : "ACTIVE",
        "freeformTags" : { },
        "definedTags" : { },
        "systemTags" : { },
        "searchContext" : {
          "highlights" : {
            "displayName" : [ "<hl>patdoerr</hl>" ],
            "name" : [ "<hl>patdoerr</hl>" ],
            "description" : [ "Pat <hl>Doerr</hl> - <hl>pat.doerr</hl>@example.com" ]
          }
        },
        "identityContext" : { },
        "additionalDetails" : { }
      } ]
    }
    

    With these results, you can take more action, if needed. For more information about a resource type, such as its attributes, see its reference page in the API Reference Guide. For the reference pages of resource types that have been indexed for Search, see Supported Resources.