Summary

The querySearchDomains() GraphQL query queries search domains with an organization filter.

Syntax

graphql
querySearchDomains(
      searchFilter: String,
      typeFilter: SearchDomainTypes!,
      sortBy: Searchdomain__SortBy!,
      orderBy: OrderBy = ASC,
      skip: Int = 0,
      limit: Int = 50,
      deleted: Boolean,
      includeHidden: Boolean,
      limitName: String
   ): SearchDomainSearchResultSet!

Filter by searchFilter (name text) or limitName (connected limit name). The required typeFilter controls whether to search repositories, views, or both. Use includeHidden to include hidden search domains. See the Input Parameters section for details.

Returns a non-nullable SearchDomainSearchResultSet object. See the Returned Values section for available fields.

Example

Raw
graphql
query {
  querySearchDomains(
     searchFilter: "metrics"
     typeFilter: Repository, 
     sortBy: Name, 
     orderBy: DESC )
  { results {id, name},
      totalResults }
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "query {
  querySearchDomains(
     searchFilter: \"metrics\"
     typeFilter: Repository, 
     sortBy: Name, 
     orderBy: DESC )
  { results {id, name},
      totalResults }
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "query {
  querySearchDomains(
     searchFilter: \"metrics\"
     typeFilter: Repository, 
     sortBy: Name, 
     orderBy: DESC )
  { results {id, name},
      totalResults }
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "query { ^
  querySearchDomains( ^
     searchFilter: \"metrics\" ^
     typeFilter: Repository,  ^
     sortBy: Name,  ^
     orderBy: DESC ) ^
  { results {id, name}, ^
      totalResults } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query {
  querySearchDomains(
     searchFilter: \"metrics\"
     typeFilter: Repository, 
     sortBy: Name, 
     orderBy: DESC )
  { results {id, name},
      totalResults }
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $query = "query {
  querySearchDomains(
     searchFilter: \"metrics\"
     typeFilter: Repository, 
     sortBy: Name, 
     orderBy: DESC )
  { results {id, name},
      totalResults }
}";
$query =~ s/\n/ /g;
my $json = sprintf('{"query" : "%s"}',$query);
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");

$req->content( $json );

my $lwp = LWP::UserAgent->new;

my $result = $lwp->request( $req );

print $result->{"_content"},"\n";
Python
python
#! /usr/local/bin/python3

import requests

url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "query {
  querySearchDomains(
     searchFilter: \"metrics\"
     typeFilter: Repository, 
     sortBy: Name, 
     orderBy: DESC )
  { results {id, name},
      totalResults }
}"
}'''

resp = requests.post(url,
                     data = mydata,
                     headers = {
   "Authorization" : "Bearer $TOKEN",
   "Content-Type" : "application/json"
}
)

print(resp.text)
Node.js
javascript
const https = require('https');

const data = JSON.stringify(
    {"query" : "query {
  querySearchDomains(
     searchFilter: \"metrics\"
     typeFilter: Repository, 
     sortBy: Name, 
     orderBy: DESC )
  { results {id, name},
      totalResults }
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL',
  path: 'graphql',
  port: 443,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Authorization: 'BEARER ' + process.env.TOKEN,
    'User-Agent': 'Node',
  },
};

const req = https.request(options, (res) => {
  let data = '';
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', (d) => {
    data += d;
  });
  res.on('end', () => {
    console.log(JSON.parse(data).data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "querySearchDomains": {
      "results": [
        {
          "id": "vPKtNNHvI9z8BKcwTPKCUTSP",
          "name": "humio-metrics"
        }
      ],
      "totalResults": 1
    }
  }
}

Input Parameters

Filter by searchFilter (name text) or limitName (connected limit name). The required typeFilter controls whether to search repositories, views, or both (see second table). sortBy controls sort order (see third table). Use limit and skip for pagination.

Table: Input Parameters & Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this query. Since some of the parameters use special datatypes, additional tables for them are included below.
deleted Boolean     Whether to return only deleted search domains. This requires permission to access them.
includeHidden Boolean     Whether to include hidden repositories and views.
limit Int   50 The number of results to return.
limitName String     Filter results by name of connected limit. Search domains without a limit will be excluded.
orderBy OrderBy   ASC How to order results. See table below.
searchFilter String     Filter results based on this string.
skip Int   0 The number of results to skip, or the offset to use.
sortBy Searchdomain__SortBy yes   The basis for sorting results. See table below.
typeFilter SearchDomainTypes yes   Whether to sort results by repositories, views, or both. See table below.

The first special datatype used by this query is a simple enumerated list of types of search domains. The choices are listed here:

Table: SearchDomainTypes Enum Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
All      
Repository      
Views      

The second special datatype is an enumerated list of factors by which search domains can be sorted (for example, by name). Below is a list of choices along with brief descriptions of them:

Table: Searchdomain__SortBy Enum Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
DeletedAt      
LimitName      
Name      
Volume      

Returned Values

Returns a non-nullable SearchDomainSearchResultSet object. The table below lists all fields:

Table: SearchDomainSearchResultSet Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
resultsSearchDomainyes Long-Term The paginated result set
totalResultsIntyes Long-Term The total number of matching results