The searchOrganizations() GraphQL query is used to get paginated search results. This is a root operation.

For more information on organization settings, see the Organization Settings documentation page.

Syntax

Below is the syntax for the searchOrganizations() query field:

graphql
searchOrganizations(
     searchFilter: string
     limit: integer
     skip: integer
     typeFilter: [Organizations__SearchEntryType!]
     subscriptionFilter: [Organizations__Subscription!]
     sortBy: Organizations__SortBy!
     orderBy: OrderBy
   ): OrganizationSearchResultSet!

For the input, there are several parameters, with some choices for each special datatype. They're described in the Given Datatypes section below. What to use for the return, for OrganizationSearchResultSet is listed in the Results Datatypes section. Before reviewing those tables, look at this example:

Raw
graphql
query {
  searchOrganizations(
    typeFilter: Organization
    subscriptionFilter: Paying
    sortBy: Name
    orderBy: ASC
  )
   {totalResults, 
    results {organizationId, organizationName, userCount}}
}
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 {
  searchOrganizations(
    typeFilter: Organization
    subscriptionFilter: Paying
    sortBy: Name
    orderBy: ASC
  )
   {totalResults, 
    results {organizationId, organizationName, userCount}}
}"
}
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 {
  searchOrganizations(
    typeFilter: Organization
    subscriptionFilter: Paying
    sortBy: Name
    orderBy: ASC
  )
   {totalResults, 
    results {organizationId, organizationName, userCount}}
}"
}
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 { ^
  searchOrganizations( ^
    typeFilter: Organization ^
    subscriptionFilter: Paying ^
    sortBy: Name ^
    orderBy: ASC ^
  ) ^
   {totalResults,  ^
    results {organizationId, organizationName, userCount}} ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query {
  searchOrganizations(
    typeFilter: Organization
    subscriptionFilter: Paying
    sortBy: Name
    orderBy: ASC
  )
   {totalResults, 
    results {organizationId, organizationName, userCount}}
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $INGEST_TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $json = '{"query" : "query {
  searchOrganizations(
    typeFilter: Organization
    subscriptionFilter: Paying
    sortBy: Name
    orderBy: ASC
  )
   {totalResults, 
    results {organizationId, organizationName, userCount}}
}"
}';
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 {
  searchOrganizations(
    typeFilter: Organization
    subscriptionFilter: Paying
    sortBy: Name
    orderBy: ASC
  )
   {totalResults, 
    results {organizationId, organizationName, userCount}}
}"
}'''

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 {
  searchOrganizations(
    typeFilter: Organization
    subscriptionFilter: Paying
    sortBy: Name
    orderBy: ASC
  )
   {totalResults, 
    results {organizationId, organizationName, userCount}}
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL/graphql',
  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": {
    "searchOrganizations": {
      "totalResults": 1,
      "results": [
        {
          "organizationId": "SINGLE_ORGANIZATION_ID",
          "organizationName": "SingleOrganization",
          "userCount": 18
        }
      ]
    }
  }
}

Given Datatypes

The given datatypes are described in the table below:

Table: Mix of Input for searchOrganizations

ParameterTypeRequiredDefaultDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
Table last updated: Sep 6, 2024
searchFilterstring  Text on which to search list of organizations for filtering.
limitinteger 50The maximum number of rows to return.
skipinteger 0The initial number of rows to skip; display only rows after number given.
typeFilterOrganizations__SearchEntryTypeyes Indicates the type of data entry by which to filter the organization data.
   Valid Values
   OrganizationFilter results returned on organizations.
   RepositoryFilter results on repository, returning organizations associated with the currently selected repository.
   UserReturn list of users with information on the organizations with which they're associated.
   ViewReturn list of views and the organization to which they belong.
subscriptionFilterOrganizations__Subscriptionyes Return data on organizations that have a given LogScale subscription (e.g., Paying, Trial).
   Valid Values
   Churned
   ClusterOwner
   CommunityLocked
   CommunityUnlocked
   Complementary
   Internal
   MissingTOSAcceptance
   OnPremMonitor
   Partner
   Paying
   PostTrial
   PreTrial
   Trial
   Unknown
   UnlimitedPoC
sortByOrganizations__SortByyes Indicates the field by which to sort the session data returned (e.g., organization names).
   Valid Values
   CreatedAtSort results returned by where organization was created.
   NameSort results by names of organizations.
   SubscriptionSort results by type of LogScale subscriptions.
   UserCountSort results by the total number of users in each organization.
   ViewCountSort results by the number of views associated with each organization.
   VolumeSort results by the volume used by the organization.
orderByOrderBy ASCWhether the results should be returned in ascending or descending order.
   Valid Values
   ASCIn ascending order.
   DESCIn descending order.

Returned Datatypes

The returned datatype OrganizationSearchResultSet has its own parameters. Below is a list of them along with their datatypes and a description of each:

Table: OrganizationSearchResultSet

ParameterTypeRequiredDefaultDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
Table last updated: Sep 27, 2024
results[OrganizationSearchResultEntry]yes The paginated result set. See OrganizationSearchResultEntry.
totalResultsintegeryes The total number of matching results.