EnterpriseGlobalSearchSession
  public
  
  
  
  class
  EnterpriseGlobalSearchSession
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.app.appsearch.EnterpriseGlobalSearchSession | 
Provides a connection to all enterprise (work profile) AppSearch databases the querying application has been granted access to.
This session can be created from any user profile but will only properly return results when created from the main profile. If the user is not the main profile or an associated work profile does not exist, queries will still successfully complete but with empty results.
Schemas must be explicitly tagged enterprise and may require additional permissions to be
 visible from an enterprise session. Retrieved documents may also have certain fields restricted
 or modified unlike if they were retrieved directly from GlobalSearchSession on the work
 profile.
 
This class is thread safe.
See also:
Summary
| Public methods | |
|---|---|
| 
        
        
        
        
        
        void | 
      getByDocumentId(String packageName, String databaseName, GetByDocumentIdRequest request, Executor executor, BatchResultCallback<String, GenericDocument> callback)
      Retrieves  | 
| 
        
        
        
        
        
        void | 
      getSchema(String packageName, String databaseName, Executor executor, Consumer<AppSearchResult<GetSchemaResponse>> callback)
      Retrieves the collection of schemas most recently successfully provided to  | 
| 
        
        
        
        
        
        void | 
      openBlobForRead(Set<AppSearchBlobHandle> handles, Executor executor, Consumer<AppSearchResult<OpenBlobForReadResponse>> callback)
      Opens a batch of AppSearch Blobs for reading. | 
| 
        
        
        
        
        
        SearchResults | 
      search(String queryExpression, SearchSpec searchSpec)
      Retrieves documents from all AppSearch databases that the querying application has access to. | 
| Inherited methods | |
|---|---|
Public methods
getByDocumentId
public void getByDocumentId (String packageName, String databaseName, GetByDocumentIdRequest request, Executor executor, BatchResultCallback<String, GenericDocument> callback)
Retrieves GenericDocument documents, belonging to the specified package name and
 database name and identified by the namespace and ids in the request, from the GlobalSearchSession database.
 
If the package or database doesn't exist or if the calling package doesn't have access,
 the gets will be handled as failures in an AppSearchBatchResult object in the
 callback.
| Parameters | |
|---|---|
| packageName | String: the name of the package to get from
 This value cannot benull. | 
| databaseName | String: the name of the database to get from
 This value cannot benull. | 
| request | GetByDocumentIdRequest: a request containing a namespace and IDs to get documents for.
 This value cannot benull. | 
| executor | Executor: Executor on which to invoke the callback.
 This value cannot benull.
 Callback and listener events are dispatched through thisExecutor, providing an easy way to control which thread is
 used. To dispatch events through the main thread of your
 application, you can useContext.getMainExecutor().
 Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| callback | BatchResultCallback: Callback to receive the pending result of performing this operation. The keys
     of the returnedAppSearchBatchResultare the input IDs. The values are the
     returnedGenericDocuments on success, or a failedAppSearchResultotherwise. IDs that are not found will return a failedAppSearchResultwith a
     result code ofAppSearchResult.RESULT_NOT_FOUND. If an unexpected internal error
     occurs in the AppSearch service,BatchResultCallback.onSystemErrorwill be
     invoked with aThrowable.
 This value cannot benull. | 
getSchema
public void getSchema (String packageName, String databaseName, Executor executor, Consumer<AppSearchResult<GetSchemaResponse>> callback)
Retrieves the collection of schemas most recently successfully provided to AppSearchSession.setSchema(SetSchemaRequest, Executor, Executor, Consumer) for any types belonging to the requested package and database
 that the caller has been granted access to.
 
If the requested package/database combination does not exist or the caller has not been granted access to it, then an empty GetSchemaResponse will be returned.
| Parameters | |
|---|---|
| packageName | String: the package that owns the requestedAppSearchSchemainstances.
 This value cannot benull. | 
| databaseName | String: the database that owns the requestedAppSearchSchemainstances.
 This value cannot benull. | 
| executor | Executor: Executor on which to invoke the callback.
 This value cannot benull.
 Callback and listener events are dispatched through thisExecutor, providing an easy way to control which thread is
 used. To dispatch events through the main thread of your
 application, you can useContext.getMainExecutor().
 Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| callback | Consumer: The pendingGetSchemaResponsecontaining the schemas that the caller
     has access to or an empty GetSchemaResponse if the request package and database does not
     exist, has not set a schema or contains no schemas that are accessible to the caller.
 This value cannot benull. | 
openBlobForRead
public void openBlobForRead (Set<AppSearchBlobHandle> handles, Executor executor, Consumer<AppSearchResult<OpenBlobForReadResponse>> callback)
Opens a batch of AppSearch Blobs for reading.
See AppSearchSession.openBlobForRead for a general description when a blob is for
 read.
 
The returned OpenBlobForReadResponse must be closed after use to
 avoid resource leaks. Failing to close it will result in system file descriptor exhaustion.
| Parameters | |
|---|---|
| handles | Set: TheAppSearchBlobHandles that identifies the blobs.
 This value cannot benull. | 
| executor | Executor: Executor on which to invoke the callback.
 This value cannot benull.
 Callback and listener events are dispatched through thisExecutor, providing an easy way to control which thread is
 used. To dispatch events through the main thread of your
 application, you can useContext.getMainExecutor().
 Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| callback | Consumer: Callback to receive theOpenBlobForReadResponse.
 This value cannot benull. | 
search
public SearchResults search (String queryExpression, SearchSpec searchSpec)
Retrieves documents from all AppSearch databases that the querying application has access to.
Applications can be granted access to documents by specifying SetSchemaRequest.Builder.setSchemaTypeVisibilityForPackage(String, boolean, PackageIdentifier) when building a schema.
 
Document access can also be granted to system UIs by specifying SetSchemaRequest.Builder.setSchemaTypeDisplayedBySystem(String, boolean) when building a schema.
 
See AppSearchSession.search for a detailed explanation on forming a query string.
 
This method is lightweight. The heavy work will be done in SearchResults.getNextPage(Executor, Consumer).
| Parameters | |
|---|---|
| queryExpression | String: query string to search.
 This value cannot benull. | 
| searchSpec | SearchSpec: spec for setting document filters, adding projection, setting term match
     type, etc.
 This value cannot benull. | 
| Returns | |
|---|---|
| SearchResults | a SearchResultsobject for retrieved matched documents.
 This value cannot benull. | 
