AppSearch

AppSearch is an on-device search library for managing locally stored structured data, with APIs for indexing data and retrieving data using full-text search. Use it to build custom in-app search capabilities for your users.
Latest Update Stable Release Release Candidate Beta Release Alpha Release
September 4, 2024 - - - 1.1.0-alpha05

Declaring dependencies

To add a dependency on AppSearch, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

Groovy

dependencies {
    def appsearch_version = "1.1.0-alpha05"

    implementation "androidx.appsearch:appsearch:$appsearch_version"
    // Use kapt instead of annotationProcessor if writing Kotlin classes
    annotationProcessor "androidx.appsearch:appsearch-compiler:$appsearch_version"

    implementation "androidx.appsearch:appsearch-local-storage:$appsearch_version"
    // PlatformStorage is compatible with Android 12+ devices, and offers additional features
    // to LocalStorage.
    implementation "androidx.appsearch:appsearch-platform-storage:$appsearch_version"
}

Kotlin

dependencies {
    val appsearch_version = "1.1.0-alpha05"

    implementation("androidx.appsearch:appsearch:$appsearch_version")
    // Use annotationProcessor instead of kapt if writing Java classes
    kapt("androidx.appsearch:appsearch-compiler:$appsearch_version")

    implementation("androidx.appsearch:appsearch-local-storage:$appsearch_version")
    // PlatformStorage is compatible with Android 12+ devices, and offers additional features
    // to LocalStorage.
    implementation("androidx.appsearch:appsearch-platform-storage:$appsearch_version")
}

For more information about dependencies, see Add Build Dependencies.

Feedback

Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.

Create a new issue

See the Issue Tracker documentation for more information.

Version 1.1

Version 1.1.0-alpha05

September 4, 2024

androidx.appsearch:appsearch-*:1.1.0-alpha05 is released. Version 1.1.0-alpha05 contains these commits.

API Changes

  • Deprecates unnecessary setEmbeddingSearchEnabled and getEmbeddingSearchEnabled. Deletes setListFilterTokenizeFunctionEnabled and getListFilterTokenizeFunctionEnabled. Deleted the 'tokenize' query function. Replaced with getSearchStringParameter query function and addSearchStringParameter function. (I09f5a)
  • Rename Alarm#getComputingDevice to getOriginatingDevice. (I63121)

Version 1.1.0-alpha04

August 7, 2024

androidx.appsearch:appsearch-*:1.1.0-alpha04 is released. Version 1.1.0-alpha04 contains these commits.

New Features

  • Support for new PlayServicesStorage implementation, which allows using AppSearch on older devices without incurring the significant apk size cost of LocalStorage. This storage implementation works by storing app data within the Play Services app.
  • Support for new APIs on devices running Android 15.
  • Support searching the database by embedding vectors, allowing for fuzzy matching. (I2b41b)
  • Support parent types and polymorphism within the AppSearch schema model. (I06118)
  • Support the TakenAction API which allows apps to report when results were clicked or abandoned, for quality boosting during subsequent searches. (I54091)
  • Support classes with builders in the annotation processor by introducing the new @Document.BuilderProducer annotation. (Iec30a)
  • Support finer-grained control over which properties of a nested document get indexed. (Iec30a)
  • Support for filtering searches to certain document properties. (Ib2659)
  • Support finer-grained visibility settings by allowing OR and AND of visibility settings. (I0274b)
  • Support for granting visibility of data to all apps that can see the existence of the owning app (public visibility). (I992e4)
  • Support for retrieving only results that have data populated in a certain property. (I7d94f)
  • Support for retrieving enterprise contacts in the personal profile. (Idd587)

API Changes

  • Add indexableNestedPropertiesList and inheritIndexableNestedPropertiesFromSuperclass annotation parameters to AppSearch's Document.DocumentProperty annotation to allow indexing specific nested property paths. (Iec30a)
  • Support builder constructor to create builder instances in AppSearch annotation processor (I265c9)
  • Update AppSearch annotation processor to support setting parent types for polymorphism (I06118)
  • Adds GetSchemaRequest method for clearing visibility settings (I38379)
  • Support addParentType in AppSearch for polymorphism (Ida14a)
  • Add APIs for additional ranking expressions (I5d9f4)
  • Add SearchAction API (I54091)
  • Adds description field for AppSearch types (I84762)
  • Onboard embedding search query and ranking APIs to AppSearch (I0f6c3)
  • Removes getDeletionPropagation (I21192)

Version 1.1.0-alpha03

May 24, 2023

androidx.appsearch:appsearch-*:1.1.0-alpha03 is released. Version 1.1.0-alpha03 contains these commits.

New Features

  • Support for an advanced query API, advanced scoring API, and numeric search. (I02d48)
  • Adds LocalStorage.createGlobalSearchSession API to search across all databases within the local storage of a single app. (Id3c89)
  • Added an API to join documents by ID (Iaecfa)
  • Support property weights to mark certain properties are more important when using RANKING_STRATEGY_RELEVANCE_SCORING. (I069b9)
  • Add Person and ContactPoint for querying Person corpus in AppSearch. (Ia58f9)
  • Added new Document type ImageObject modeled after http://schema.org/ImageObject. (I6a0c0)
  • Add a VERBATIM tokenizer which allows adding properties without interpretation by AppSearch. (I47bc0)
  • Added RFC822_TOKENIZATION as a tokenizer type, allowing tokenization of email addresses. (I8a390)
  • Enable Global Search in the Debug View. (I51fb2)

API Changes

  • Removed methods that return ListenableFuture and don't have Async suffix. (I0515f)
  • Adds the ability to configure projections by a Document class. (I94576)
  • Add fields from Thing to Alarm, AlarmInstance, Timer, Stopwatch, StopwatchLap, ContactPoint, and Person (Id876c)

Bug Fixes

  • Fully support Android 13 features in appsearch-platform-storage (Ia8e61)
  • Fix issues with overriding schema names and private fields when using inheritance.

Version 1.1.0-alpha02

August 24, 2022

androidx.appsearch:appsearch-*:1.1.0-alpha02 is released. Version 1.1.0-alpha02 contains these commits.

New Features

  • Sped up Optimize process using index compaction rather than rebuilding index from scratch
  • Changed native logging tag from "icing" to "AppSearchIcing", log INFO messages by default

API Changes

  • Adds new PropertyPath object for working with paths, and new addProjection methods to accept PropertyPath. (I45588)
  • Added builtin:Thing to AppSearch builtin types (I55427)
  • Prevent empty property names in GenericDocument sooner – previously they were prevented at indexing time, now they are prevented at GenericDocument.Builder.build() time (I9e780)

Bug Fixes

  • Removed unnecessary string formatting to improve RELEVANCE scoring performance
  • More efficient pagination when encountering unreadable or deleted documents
  • Implemented garbage collection for abandoned queries
  • Fix nested indexing support for Documents. Previously indexNestedProperties was ignored. (Iae9a6)

External Contribution

  • Shea Smith: Fix nested indexing support for Documents. (Iae9a6)

Version 1.1.0-alpha01

June 15, 2022

androidx.appsearch:appsearch-*:1.1.0-alpha01 is released. Version 1.1.0-alpha01 was developed in a private pre-release branch and has no public commits.

API Changes

  • All methods returning ListenableFuture have been renamed to have the Async suffix. For example, getSchema has been renamed to getSchemaAsync. The previous versions have been deprecated and will be removed in a future release.

New Features

  • First release of appsearch-builtin-types. This project contains some builtin types based on schema.org which clients may find convenient to use instead of defining their own types for common objects. More types will be added in future releases.
  • Ability to use ShortcutAdapter to convert an AppSearch Document into a ShortcutInfoCompat. This gives clients a way to share AppSearch documents to Google using the core-google-shortcuts library
  • Ability to use inheritance with @Document classes. Fields cannot be replaced or modified, but new fields can be added by extending a class annotated with @Document.
  • New Observer API which allows clients to register for notifications when types they have access to have changed or when documents of those types are added, modified or removed. IMPORTANT: The current implementation delivers notifications only when your app is running. There is currently no way to inspect changes that have occurred while your app was stopped. Accordingly you should not rely on this API for completeness.
  • Property parser API which allows you to fully handle and inspect property paths returned by MatchInfo#getPropertyPath.
  • Global getById and global getSchema API for retrieving documents and schemas from other apps which have granted you visibility.
  • Ability to retrieve visibility information in getSchema for data you have access to
  • Ability to grant visibility to apps holding a certain Android permission (restricted to a narrow set of allowlisted permissions)
  • Support isFoo()-style getters for boolean fields in the annotation processor, in addition to the previous supported style hasFoo()
  • Support for new features guarded behind @RequiresFeature. Use AppSearchSession#getFeatures to determine what the current backend supports.
  • Remove the ~13k token limit on individual documents
  • Allow matching on non-ascii+non-alphanumeric characters, such as emojis

Bug Fixes

  • Fix bug that would fail SetSchema when overriding a nested incompatible type.
  • Fixes to fully support @AutoValue-annotated classes being used as AppSearch @Document classes
  • Fixes for some crashes related to repeated lists of Document classes and other issues
  • Fix for bug that would crash prefix search under certain circumstances
  • Fix minor bug in GetStorageInfo that would return incorrect values when encountering IO failures
  • Fix BUSADDERR issues when reading a document
  • Fix logcat corruption caused by printing unformatted fingerprint
  • Fix NPE caused by IO failures
  • Fix memory leak in GetSchemaType, Get, Delete, DeleteByNamespace and DeleteBySchemaType

Version 1.0.0

Version 1.0.0-alpha04

November 3, 2021

androidx.appsearch:appsearch-*:1.0.0-alpha04 is released. Version 1.0.0-alpha04 contains these commits.

New Features

  • Guava ListenableFuture dependency automatically brought in as an API dependency

API Changes

  • Add SearchResult#getSubmatchRange() and SearchResult#getSubmatch() to provide more information about each match. (I2fef6)
  • Clarify documentation around how to generate PackageIdentifier fingerprints for sharing data by packagename+certificate

Bug Fixes

  • Fix crash if user tries to fetch result pages after the end of the result set
  • Fix issue with all namespaces being queried if only invalid namespaces were supplied as query filters
  • Fix issue with all namespaces being removed if only invalid namespaces were supplied as remove-by-query filtersLo
  • Fix issue where document data stopped being indexed after a certain point for very large documents
  • Fix issue where tokenization would drop segments with non-Ascii numeric characters
  • Add check for consecutive failed initialization attempts to help break out of potential bad state that prevents successful initialization.

Version 1.0.0-alpha03

July 21, 2021

androidx.appsearch:appsearch-*:1.0.0-alpha03 is released. Version 1.0.0-alpha03 contains these commits.

New Features

  • Release of the Platform Storage Backend to allow clients to use the AppSearch API with the new android.app.appsearch.AppSearchManager service launching in Android S. For more details, please visit AppSearch Developer Guide.
  • Annotation processor support for AutoValue
  • Removal of maximum size limit of single string property
  • New storage format to reduce initialization latency
  • A one-time, internal data migration from old storage format to new storage format

Bug Fixes

  • Correctly enforces maximum document limit when inserting new documents
  • Fixed crash during AppSearchSession creation
  • Fixed bugs in SetSchema that were not detecting some cases of backwards incompatibility and index incompatibility

Version 1.0.0-alpha02

June 30, 2021

androidx.appsearch:appsearch:1.0.0-alpha02, androidx.appsearch:appsearch-compiler:1.0.0-alpha02, and androidx.appsearch:appsearch-local-storage:1.0.0-alpha02 are released. Version 1.0.0-alpha02 contains these commits.

New Features

  • Full support of Chinese/Japanese/Korean/Thai languages
  • Reduced size of androidx.appsearch:appsearch-local-storage
  • Removal of maximum size limit of repeated properties
  • Allow reuse of builder classes
  • Improvements in toString() of certain objects for easier debugging
  • Javadoc documentation improvements

API Changes

  • SearchResult#getMatches renamed to SearchResult#getMatchInfos
  • @Document.Int64Property renamed to @Document.LongProperty

Bug Fixes

  • Improvements and fixes to computation of result snippets
  • Fixes to bugs in AppSearchSession initialization

Version 1.0.0-alpha01

May 5, 2021

androidx.appsearch:appsearch:1.0.0-alpha01, androidx.appsearch:appsearch-compiler:1.0.0-alpha01, and androidx.appsearch:appsearch-local-storage:1.0.0-alpha01 are released. Version 1.0.0-alpha01 contains these commits.

New Features

AppSearch is a search library for managing locally stored structured data, with APIs for indexing data and retrieving data via full-text search. Use it to build custom in-app search capabilities for your users. This initial release is 1.0.0-alpha01.