The entitiesSearch() is used to query assets across LogScale views and repositories. It will return only the first page. The response includes a cursor that can be sent to entitiesPage() to get next or previous pages with the same parameters.

Syntax

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

graphql
entitiesSearch(
     input: EntitySearchInputType!
   ): SearchResult!

For the input, you'd enter input, followed by a colon and what you want to input between curly-brackets. The parameters for EntitySearchInputType are listed in the Given Datatypes section below. For the results returned, you'd list them after the closing parenthesis, within its own curly-brackets. For SearchResult parameters see the Results Datatypes section.

The example below requests information on specific entityTypes, on Dashboards containing "sales" in the name of the dashboards. It says also to group the results into 5 per page. The results are shown afterwards. Notice that we've requested the uniqud identifier for the cursor. That's needed to get the next or previous page.

Raw
graphql
query {
  entitiesSearch(
    input: {searchTerm: "sales", 
            entityTypes: [Dashboard], 
            pageSize: 5}
  ) { totalResults, cursor,
      hasPreviousPage, hasNextPage }
}
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 {
  entitiesSearch(
    input: {searchTerm: \"sales\", 
            entityTypes: [Dashboard], 
            pageSize: 5}
  ) { totalResults, cursor,
      hasPreviousPage, hasNextPage }
}"
}
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 {
  entitiesSearch(
    input: {searchTerm: \"sales\", 
            entityTypes: [Dashboard], 
            pageSize: 5}
  ) { totalResults, cursor,
      hasPreviousPage, hasNextPage }
}"
}
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 { ^
  entitiesSearch( ^
    input: {searchTerm: \"sales\",  ^
            entityTypes: [Dashboard],  ^
            pageSize: 5} ^
  ) { totalResults, cursor, ^
      hasPreviousPage, hasNextPage } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query {
  entitiesSearch(
    input: {searchTerm: \"sales\", 
            entityTypes: [Dashboard], 
            pageSize: 5}
  ) { totalResults, cursor,
      hasPreviousPage, hasNextPage }
}"
}'
"$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 {
  entitiesSearch(
    input: {searchTerm: \"sales\", 
            entityTypes: [Dashboard], 
            pageSize: 5}
  ) { totalResults, cursor,
      hasPreviousPage, hasNextPage }
}"
}';
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 {
  entitiesSearch(
    input: {searchTerm: \"sales\", 
            entityTypes: [Dashboard], 
            pageSize: 5}
  ) { totalResults, cursor,
      hasPreviousPage, hasNextPage }
}"
}'''

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 {
  entitiesSearch(
    input: {searchTerm: \"sales\", 
            entityTypes: [Dashboard], 
            pageSize: 5}
  ) { totalResults, cursor,
      hasPreviousPage, hasNextPage }
}"
}
);


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": {
    "entitiesSearch": {
      "totalResults": 15,
      "cursor": "eyJlbnRpdHlU..."
      "hasPreviousPage": false,
      "hasNextPage": true
    }
  },
  "extensions": {
    "preview": [
      {
        "name": "entitiesSearch",
        "reason": "[PREVIEW: Under development]"
      }
    ]
  }
}

Notice that the example above requests a count of the totalResults, which are grouped per the input by five per page. It also asks whether there is a previous and next page. You would use these return values in variables in whatever API program you might write and use. The value for the cursor is shortened here. It's normally very long. You'd capture that value and send it to entitiesPage() .

Given Datatypes

For EntitySearchInputType, there are a few parameters that may be given. Below is a list of them along with their datatypes and a description of each:

Table: EntitySearchInputType

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 18, 2024
entityTypes[EntitySearchEntityType]yes The types of entity. See EntitySearchEntityType.
pageSizeinteger 100The number of records to return per page.
paths[string]yes Theh paths to search.
searchTermstring  Text on which to search assets in views and repositories.
sortBy[EntitySearchSortInfoType]yes Enter name with a string for the field on which to sort. See EntitySearchSortInfoType.

Returned Datatypes

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

Table: SearchResult

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.
cursorstring  The cursor useds for going to the next or previous page.
data[EntitySearchResultEntity]yes The results of the search. See ViewInteractionEntry, FileEntry, and DashboardEntry.
hasNextPagebooleanyes Whether there is a next page. False indicates it's the last page.
hasPreviousPagebooleanyes Whether there is a previous page. False indicates it's the first page.
totalResultsintegeryes The total number of results that matched the search query. Only pageSize elements will be returned.