A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/android/reference/com/google/android/gms/appsearch/AppSearchManager below:

AppSearchManager | Google Play services

AppSearchManager

Stay organized with collections Save and categorize content based on your preferences.

Provides access to the centralized AppSearch index maintained by the system.

AppSearch is an offline, on-device search library for managing structured data featuring:

Applications create a database by opening an AppSearchClient.

Example:

 AppSearchManager appSearchManager = context.getSystemService(AppSearchManager.class);

 AppSearchManager.SearchContext searchContext = new AppSearchManager.SearchContext.Builder().
    setDatabaseName(dbName).build());
 appSearchManager.createSearchSession(searchContext, mExecutor, AppSearchClientResult -> {
      mAppSearchClient = AppSearchClientResult.getResultValue();
 });

After opening the session, a schema must be set in order to define the organizational structure of data. The schema is set by calling AppSearchClient.setSchema(SetSchemaRequest, String). The schema is composed of a collection of AppSearchSchema objects, each of which defines a unique type of data.

Example:

 AppSearchSchema emailSchemaType = new AppSearchSchema.Builder("Email")
     .addProperty(new StringPropertyConfig.Builder("subject")
        .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
        .setIndexingType(PropertyConfig.INDEXING_TYPE_PREFIXES)
        .setTokenizerType(PropertyConfig.TOKENIZER_TYPE_PLAIN)
    .build()
 ).build();

 SetSchemaRequest request = new SetSchemaRequest.Builder().addSchema(emailSchemaType).build();
 mAppSearchClient.set(request, mExecutor, appSearchResult -> {
      if (appSearchResult.isSuccess()) {
           // Schema has been successfully set.
      }
 });

The basic unit of data in AppSearch is represented as a GenericDocument object, containing an ID, namespace, time-to-live, score, and properties. A namespace organizes a logical group of documents. For example, a namespace can be created to group documents on a per-account basis. An ID identifies a single document within a namespace. The combination of namespace and ID uniquely identifies a GenericDocument in the database.

Once the schema has been set, GenericDocument objects can be put into the database and indexed by calling AppSearchClient.put(PutDocumentsRequest, String).

Example:

 // Although for this example we use GenericDocument directly, we recommend extending
 // GenericDocument to create specific types (i.e. Email) with specific setters/getters.
 GenericDocument email = new GenericDocument.Builder<>(NAMESPACE, ID, EMAIL_SCHEMA_TYPE)
     .setPropertyString(“subject”, EMAIL_SUBJECT)
     .setScore(EMAIL_SCORE)
     .build();

 PutDocumentsRequest request = new PutDocumentsRequest.Builder().addGenericDocuments(email)
     .build();
 mAppSearchClient.put(request, mExecutor, appSearchBatchResult -> {
      if (appSearchBatchResult.isSuccess()) {
           // All documents have been successfully indexed.
      }
 });

Searching within the database is done by calling AppSearchClient.search(String, SearchSpec, String) and providing the query string to search for, as well as a SearchSpec.

Alternatively, AppSearchClient.getByDocumentId(GetByDocumentIdRequest, String) can be called to retrieve documents by namespace and ID.

Document removal is done either by time-to-live expiration, or explicitly calling a remove operation. Remove operations can be done by namespace and ID via AppSearchClient.remove(RemoveByDocumentIdRequest, String), or by query via AppSearchClient.remove(String, SearchSpec, String).

Nested Class Summary Inherited Method Summary From class java.lang.Object Object

clone()

boolean void

finalize()

final Class<?>

getClass()

int

hashCode()

final void

notify()

final void

notifyAll()

String

toString()

final void

wait(long arg0, int arg1)

final void

wait(long arg0)

final void

wait()

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-10-31 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["`AppSearchManager` provides an on-device, offline search library for managing structured data using full-text search."],["Applications can grant read-access permission to other applications and control data visibility on System UI surfaces."],["Data is organized with schemas, documents are indexed by namespace and ID, and retrieval is done via search or direct document ID."],["`AppSearchClient` is used to interact with the AppSearch database for operations like setting schemas, indexing documents, searching, and removing data."],["Documents can be removed explicitly or by time-to-live expiration, providing flexibility in data management."]]],["AppSearchManager facilitates on-device data management and search. Key actions include: creating a database via `AppSearchClient`, defining data structure with `AppSearchSchema` in `SetSchemaRequest`, and indexing data using `GenericDocument` via `PutDocumentsRequest`. Data visibility to other apps and system UI is configurable. Search is performed via queries in `SearchSpec`, or by document ID. Documents can be removed by time-to-live, ID, or query.\n"]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4