| GitHub Repository | Product Reference |
Service Description: SearchService provides methods for searching data in Chronicle.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
String query = "query107944136";
Interval timeRange = Interval.newBuilder().build();
SearchSession response = searchServiceClient.searchAsync(parent, query, timeRange).get();
}
Note: close() needs to be called on the SearchServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
Search |
Initiates a long-running search operation. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListSearchedResults |
Retrieves results from a completed Search operation. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of SearchServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
SearchServiceSettings searchServiceSettings =
SearchServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
SearchServiceSettings searchServiceSettings =
SearchServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
SearchServiceSettings searchServiceSettings =
SearchServiceSettings.newHttpJsonBuilder().build();
SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
public static final SearchServiceClient create()Constructs an instance of SearchServiceClient with default settings.
| Returns | |
|---|---|
| Type | Description |
SearchServiceClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(SearchServiceSettings settings)
public static final SearchServiceClient create(SearchServiceSettings settings)Constructs an instance of SearchServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
| Parameter | |
|---|---|
| Name | Description |
settings |
SearchServiceSettings |
| Returns | |
|---|---|
| Type | Description |
SearchServiceClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(SearchServiceStub stub)
public static final SearchServiceClient create(SearchServiceStub stub)Constructs an instance of SearchServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(SearchServiceSettings).
| Parameter | |
|---|---|
| Name | Description |
stub |
SearchServiceStub |
| Returns | |
|---|---|
| Type | Description |
SearchServiceClient |
|
Constructors
SearchServiceClient(SearchServiceSettings settings)
protected SearchServiceClient(SearchServiceSettings settings)Constructs an instance of SearchServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
| Parameter | |
|---|---|
| Name | Description |
settings |
SearchServiceSettings |
SearchServiceClient(SearchServiceStub stub)
protected SearchServiceClient(SearchServiceStub stub)| Parameter | |
|---|---|
| Name | Description |
stub |
SearchServiceStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)| Parameters | |
|---|---|
| Name | Description |
duration |
long |
unit |
TimeUnit |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
| Exceptions | |
|---|---|
| Type | Description |
InterruptedException |
|
close()
public final void close()getHttpJsonOperationsClient()
public final OperationsClient getHttpJsonOperationsClient()Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
| Returns | |
|---|---|
| Type | Description |
OperationsClient |
|
getOperationsClient()
public final OperationsClient getOperationsClient()Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
| Returns | |
|---|---|
| Type | Description |
OperationsClient |
|
getSettings()
public final @Nullable SearchServiceSettings getSettings()| Returns | |
|---|---|
| Type | Description |
@org.jspecify.annotations.Nullable com.google.cloud.chronicle.v1.SearchServiceSettings |
|
getStub()
public SearchServiceStub getStub()| Returns | |
|---|---|
| Type | Description |
SearchServiceStub |
|
isShutdown()
public boolean isShutdown()| Returns | |
|---|---|
| Type | Description |
boolean |
|
isTerminated()
public boolean isTerminated()| Returns | |
|---|---|
| Type | Description |
boolean |
|
listSearchedResults(@Nullable SearchSessionName parent)
public final SearchServiceClient.ListSearchedResultsPagedResponse listSearchedResults(@Nullable SearchSessionName parent)Retrieves results from a completed Search operation.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) {
SearchSessionName parent =
SearchSessionName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[SEARCH_SESSION]");
for (SearchedResult element : searchServiceClient.listSearchedResults(parent).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
@org.jspecify.annotations.Nullable com.google.cloud.chronicle.v1.SearchSessionNameRequired. The parent SearchSession resource name. Format: projects/{project}/locations/{location}/instances/{instance}/searchSessions/{search_session} |
| Returns | |
|---|---|
| Type | Description |
SearchServiceClient.ListSearchedResultsPagedResponse |
|
listSearchedResults(ListSearchedResultsRequest request)
public final SearchServiceClient.ListSearchedResultsPagedResponse listSearchedResults(ListSearchedResultsRequest request)Retrieves results from a completed Search operation.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) {
ListSearchedResultsRequest request =
ListSearchedResultsRequest.newBuilder()
.setParent(
SearchSessionName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[SEARCH_SESSION]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
for (SearchedResult element : searchServiceClient.listSearchedResults(request).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
request |
ListSearchedResultsRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
SearchServiceClient.ListSearchedResultsPagedResponse |
|
listSearchedResults(String parent)
public final SearchServiceClient.ListSearchedResultsPagedResponse listSearchedResults(String parent)Retrieves results from a completed Search operation.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) {
String parent =
SearchSessionName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[SEARCH_SESSION]")
.toString();
for (SearchedResult element : searchServiceClient.listSearchedResults(parent).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
StringRequired. The parent SearchSession resource name. Format: projects/{project}/locations/{location}/instances/{instance}/searchSessions/{search_session} |
| Returns | |
|---|---|
| Type | Description |
SearchServiceClient.ListSearchedResultsPagedResponse |
|
listSearchedResultsCallable()
public final UnaryCallable<ListSearchedResultsRequest,ListSearchedResultsResponse> listSearchedResultsCallable()Retrieves results from a completed Search operation.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) {
ListSearchedResultsRequest request =
ListSearchedResultsRequest.newBuilder()
.setParent(
SearchSessionName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[SEARCH_SESSION]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
while (true) {
ListSearchedResultsResponse response =
searchServiceClient.listSearchedResultsCallable().call(request);
for (SearchedResult element : response.getSearchedResultsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListSearchedResultsRequest,ListSearchedResultsResponse> |
|
listSearchedResultsPagedCallable()
public final UnaryCallable<ListSearchedResultsRequest,SearchServiceClient.ListSearchedResultsPagedResponse> listSearchedResultsPagedCallable()Retrieves results from a completed Search operation.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) {
ListSearchedResultsRequest request =
ListSearchedResultsRequest.newBuilder()
.setParent(
SearchSessionName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[SEARCH_SESSION]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
ApiFuture<SearchedResult> future =
searchServiceClient.listSearchedResultsPagedCallable().futureCall(request);
// Do something.
for (SearchedResult element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListSearchedResultsRequest,ListSearchedResultsPagedResponse> |
|
searchAsync(@Nullable InstanceName parent, String query, Interval timeRange)
public final OperationFuture<SearchSession,SearchOperationMetadata> searchAsync(@Nullable InstanceName parent, String query, Interval timeRange)Initiates a long-running search operation.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
String query = "query107944136";
Interval timeRange = Interval.newBuilder().build();
SearchSession response = searchServiceClient.searchAsync(parent, query, timeRange).get();
}
| Parameters | |
|---|---|
| Name | Description |
parent |
@org.jspecify.annotations.Nullable com.google.cloud.chronicle.v1.InstanceNameRequired. The resource name of the instance on which to perform the search. Format: projects/{project}/locations/{location}/instances/{instance} |
query |
StringRequired. The search query, in the dialect set in |
timeRange |
com.google.type.IntervalRequired. Time range to search for [Inclusive start time, exclusive end time). |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<SearchSession,SearchOperationMetadata> |
|
searchAsync(SearchRequest request)
public final OperationFuture<SearchSession,SearchOperationMetadata> searchAsync(SearchRequest request)Initiates a long-running search operation.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) {
SearchRequest request =
SearchRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
.setQuery("query107944136")
.setTimeRange(Interval.newBuilder().build())
.setDialect(QueryDialect.forNumber(0))
.setDraftDataAccessScope(DataAccessScope.newBuilder().build())
.setResultLimit(522988825)
.setSimulatedDataVisibility(SimulatedDataVisibility.forNumber(0))
.build();
SearchSession response = searchServiceClient.searchAsync(request).get();
}
| Parameter | |
|---|---|
| Name | Description |
request |
SearchRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<SearchSession,SearchOperationMetadata> |
|
searchAsync(String parent, String query, Interval timeRange)
public final OperationFuture<SearchSession,SearchOperationMetadata> searchAsync(String parent, String query, Interval timeRange)Initiates a long-running search operation.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString();
String query = "query107944136";
Interval timeRange = Interval.newBuilder().build();
SearchSession response = searchServiceClient.searchAsync(parent, query, timeRange).get();
}
| Parameters | |
|---|---|
| Name | Description |
parent |
StringRequired. The resource name of the instance on which to perform the search. Format: projects/{project}/locations/{location}/instances/{instance} |
query |
StringRequired. The search query, in the dialect set in |
timeRange |
com.google.type.IntervalRequired. Time range to search for [Inclusive start time, exclusive end time). |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<SearchSession,SearchOperationMetadata> |
|
searchCallable()
public final UnaryCallable<SearchRequest,Operation> searchCallable()Initiates a long-running search operation.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) {
SearchRequest request =
SearchRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
.setQuery("query107944136")
.setTimeRange(Interval.newBuilder().build())
.setDialect(QueryDialect.forNumber(0))
.setDraftDataAccessScope(DataAccessScope.newBuilder().build())
.setResultLimit(522988825)
.setSimulatedDataVisibility(SimulatedDataVisibility.forNumber(0))
.build();
ApiFuture<Operation> future = searchServiceClient.searchCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<SearchRequest,Operation> |
|
searchOperationCallable()
public final OperationCallable<SearchRequest,SearchSession,SearchOperationMetadata> searchOperationCallable()Initiates a long-running search operation.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) {
SearchRequest request =
SearchRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
.setQuery("query107944136")
.setTimeRange(Interval.newBuilder().build())
.setDialect(QueryDialect.forNumber(0))
.setDraftDataAccessScope(DataAccessScope.newBuilder().build())
.setResultLimit(522988825)
.setSimulatedDataVisibility(SimulatedDataVisibility.forNumber(0))
.build();
OperationFuture<SearchSession, SearchOperationMetadata> future =
searchServiceClient.searchOperationCallable().futureCall(request);
// Do something.
SearchSession response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
OperationCallable<SearchRequest,SearchSession,SearchOperationMetadata> |
|
shutdown()
public void shutdown()shutdownNow()
public void shutdownNow()