# EnterpriseGlobalSearchSession

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/app/EnterpriseGlobalSearchSession.java+class:androidx.appsearch.app.EnterpriseGlobalSearchSession) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***


```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.ENTERPRISE_GLOBAL_SEARCH_SESSION)
public interface EnterpriseGlobalSearchSession extends ReadOnlyGlobalSearchSession
```

<br />

*** ** * ** ***

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 `https://developer.android.com/reference/androidx/appsearch/app/GlobalSearchSession` on the work profile.

All implementations of this interface must be thread safe.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appsearch/app/GlobalSearchSession` |   |

## Summary

### Inherited methods

From [androidx.appsearch.app.ReadOnlyGlobalSearchSession](https://developer.android.com/reference/androidx/appsearch/app/ReadOnlyGlobalSearchSession) `abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/androidx/appsearch/app/GenericDocument>>` `@https://developer.android.com/reference/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/androidx/appsearch/app/Features.GLOBAL_SEARCH_SESSION_GET_BY_ID)
https://developer.android.com/reference/androidx/appsearch/app/ReadOnlyGlobalSearchSession#getByDocumentIdAsync(java.lang.String,java.lang.String,androidx.appsearch.app.GetByDocumentIdRequest)(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html packageName,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html databaseName,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/GetByDocumentIdRequest request
)`

Retrieves `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` documents, belonging to the specified package name and database name and identified by the namespace and ids in the request, from the `https://developer.android.com/reference/androidx/appsearch/app/GlobalSearchSession` database.
`abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/Features` `https://developer.android.com/reference/androidx/appsearch/app/ReadOnlyGlobalSearchSession#getFeatures()()`

Returns the `https://developer.android.com/reference/androidx/appsearch/app/Features` to check for the availability of certain features for this session.
`abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/appsearch/app/GetSchemaResponse>` `@https://developer.android.com/reference/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/androidx/appsearch/app/Features.GLOBAL_SEARCH_SESSION_GET_SCHEMA)
https://developer.android.com/reference/androidx/appsearch/app/ReadOnlyGlobalSearchSession#getSchemaAsync(java.lang.String,java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html packageName, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html databaseName)`

Retrieves the collection of schemas most recently successfully provided to `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession#setSchemaAsync(androidx.appsearch.app.SetSchemaRequest)` for any types belonging to the requested package and database that the caller has been granted access to.
`abstract void` `@https://developer.android.com/reference/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/androidx/appsearch/app/Features.GLOBAL_SEARCH_SESSION_REGISTER_OBSERVER_CALLBACK)
https://developer.android.com/reference/androidx/appsearch/app/ReadOnlyGlobalSearchSession#registerObserverCallback(java.lang.String,androidx.appsearch.observer.ObserverSpec,java.util.concurrent.Executor,androidx.appsearch.observer.ObserverCallback)(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html targetPackageName,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/observer/ObserverSpec spec,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html executor,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/observer/ObserverCallback observer
)`

Adds an `https://developer.android.com/reference/androidx/appsearch/observer/ObserverCallback` to monitor changes within the databases owned by `targetPackageName` if they match the given `https://developer.android.com/reference/androidx/appsearch/observer/ObserverSpec`.
`abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/SearchResults` `https://developer.android.com/reference/androidx/appsearch/app/ReadOnlyGlobalSearchSession#search(java.lang.String,androidx.appsearch.app.SearchSpec)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html queryExpression, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/SearchSpec searchSpec)`

Retrieves documents from all AppSearch databases that the querying application has access to.
`abstract void` `@https://developer.android.com/reference/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/androidx/appsearch/app/Features.GLOBAL_SEARCH_SESSION_REGISTER_OBSERVER_CALLBACK)
https://developer.android.com/reference/androidx/appsearch/app/ReadOnlyGlobalSearchSession#unregisterObserverCallback(java.lang.String,androidx.appsearch.observer.ObserverCallback)(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html targetPackageName,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/observer/ObserverCallback observer
)`

Removes previously registered `https://developer.android.com/reference/androidx/appsearch/observer/ObserverCallback` instances from the system.