blob: 22e00f2cdfdc30761ff0b6cf4dd5391733a04c80 [file] [log] [blame]
Terry Wangfebbead2019-10-17 17:05:18 -07001/**
sidchhabraa7c8f8a2020-01-16 18:38:17 -08002 * Copyright 2020, The Android Open Source Project
Terry Wangfebbead2019-10-17 17:05:18 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package android.app.appsearch;
Alexander Dorokhinefd07eba2020-01-13 20:22:20 -080017
Alexander Dorokhine92ce3532020-10-06 01:39:36 -070018import android.os.Bundle;
19
Terry Wangdbd1dca2020-11-03 17:03:56 -080020import android.app.appsearch.AppSearchBatchResult;
21import android.app.appsearch.AppSearchResult;
22import android.app.appsearch.IAppSearchBatchResultCallback;
23import android.app.appsearch.IAppSearchResultCallback;
Alexander Dorokhinefd07eba2020-01-13 20:22:20 -080024import com.android.internal.infra.AndroidFuture;
25
Alexander Dorokhinec66d67c2020-10-08 13:44:04 -070026parcelable SearchResults;
Alexander Dorokhine18465842020-01-21 01:08:57 -080027
Terry Wangfebbead2019-10-17 17:05:18 -070028/** {@hide} */
29interface IAppSearchManager {
Alexander Dorokhinefd07eba2020-01-13 20:22:20 -080030 /**
31 * Sets the schema.
32 *
Terry Wang6413aee2020-10-07 03:04:58 -070033 * @param databaseName The databaseName this document resides in.
Alexander Dorokhine92ce3532020-10-06 01:39:36 -070034 * @param schemaBundles List of AppSearchSchema bundles.
Alexander Dorokhine321e4b12020-01-18 11:15:00 -080035 * @param forceOverride Whether to apply the new schema even if it is incompatible. All
36 * incompatible documents will be deleted.
Terry Wangdbd1dca2020-11-03 17:03:56 -080037 * @param callback {@link IAppSearchResultCallback#onResult} will be called with an
38 * {@link AppSearchResult}<{@link Void}>.
Alexander Dorokhinefd07eba2020-01-13 20:22:20 -080039 */
Alexander Dorokhine969f4462020-03-05 15:54:19 -080040 void setSchema(
Terry Wang6413aee2020-10-07 03:04:58 -070041 in String databaseName,
Alexander Dorokhine92ce3532020-10-06 01:39:36 -070042 in List<Bundle> schemaBundles,
43 boolean forceOverride,
Terry Wangdbd1dca2020-11-03 17:03:56 -080044 in IAppSearchResultCallback callback);
Alexander Dorokhinecc223452020-01-19 03:00:28 -080045
46 /**
Alexander Dorokhine18465842020-01-21 01:08:57 -080047 * Inserts documents into the index.
Alexander Dorokhinecc223452020-01-19 03:00:28 -080048 *
Terry Wang6413aee2020-10-07 03:04:58 -070049 * @param databaseName The name of the database where this document lives.
Alexander Dorokhinec66d67c2020-10-08 13:44:04 -070050 * @param documentBundes List of GenericDocument bundles.
Alexander Dorokhine18465842020-01-21 01:08:57 -080051 * @param callback
Terry Wangdbd1dca2020-11-03 17:03:56 -080052 * If the call fails to start, {@link IAppSearchBatchResultCallback#onSystemError}
53 * will be called with the cause throwable. Otherwise,
54 * {@link IAppSearchBatchResultCallback#onResult} will be called with an
Alexander Dorokhine18465842020-01-21 01:08:57 -080055 * {@link AppSearchBatchResult}&lt;{@link String}, {@link Void}&gt;
56 * where the keys are document URIs, and the values are {@code null}.
Alexander Dorokhinecc223452020-01-19 03:00:28 -080057 */
Alexander Dorokhinec66d67c2020-10-08 13:44:04 -070058 void putDocuments(
Terry Wang6413aee2020-10-07 03:04:58 -070059 in String databaseName,
60 in List<Bundle> documentBundles,
Terry Wangdbd1dca2020-11-03 17:03:56 -080061 in IAppSearchBatchResultCallback callback);
Alexander Dorokhinecc223452020-01-19 03:00:28 -080062
sidchhabraa7c8f8a2020-01-16 18:38:17 -080063 /**
Alexander Dorokhine69a8d9f2020-03-06 10:43:16 -080064 * Retrieves documents from the index.
65 *
Terry Wang6413aee2020-10-07 03:04:58 -070066 * @param databaseName The databaseName this document resides in.
67 * @param namespace The namespace this document resides in.
Alexander Dorokhine69a8d9f2020-03-06 10:43:16 -080068 * @param uris The URIs of the documents to retrieve
Alexander Dorokhinea95f44f2020-03-06 13:53:14 -080069 * @param callback
Terry Wangdbd1dca2020-11-03 17:03:56 -080070 * If the call fails to start, {@link IAppSearchBatchResultCallback#onSystemError}
71 * will be called with the cause throwable. Otherwise,
72 * {@link IAppSearchBatchResultCallback#onResult} will be called with an
Alexander Dorokhinec66d67c2020-10-08 13:44:04 -070073 * {@link AppSearchBatchResult}&lt;{@link String}, {@link Bundle}&gt;
74 * where the keys are document URIs, and the values are Document bundles.
Alexander Dorokhine69a8d9f2020-03-06 10:43:16 -080075 */
Terry Wang6413aee2020-10-07 03:04:58 -070076 void getDocuments(
77 in String databaseName,
78 in String namespace,
79 in List<String> uris,
Terry Wangdbd1dca2020-11-03 17:03:56 -080080 in IAppSearchBatchResultCallback callback);
Alexander Dorokhine69a8d9f2020-03-06 10:43:16 -080081
82 /**
sidchhabrab0098382020-01-22 11:47:22 -080083 * Searches a document based on a given specifications.
sidchhabraa7c8f8a2020-01-16 18:38:17 -080084 *
Terry Wang6413aee2020-10-07 03:04:58 -070085 * @param databaseName The databaseName this query for.
Alexander Dorokhinec9fc9602020-10-06 01:39:50 -070086 * @param queryExpression String to search for
87 * @param searchSpecBundle SearchSpec bundle
Alexander Dorokhined48f2362020-10-20 17:40:49 -070088 * @param callback {@link AppSearchResult}&lt;{@link Bundle}&gt; of performing this
89 * operation.
sidchhabraa7c8f8a2020-01-16 18:38:17 -080090 */
Alexander Dorokhinee708e182020-03-06 15:30:34 -080091 void query(
Terry Wang6413aee2020-10-07 03:04:58 -070092 in String databaseName,
Alexander Dorokhinec9fc9602020-10-06 01:39:50 -070093 in String queryExpression,
94 in Bundle searchSpecBundle,
Alexander Dorokhined48f2362020-10-20 17:40:49 -070095 in IAppSearchResultCallback callback);
96
97 /**
Terry Wangbfbfcac2020-11-06 15:46:44 -080098 * Executes a global query, i.e. over all permitted databases, against the AppSearch index and
99 * returns results.
100 *
101 * @param queryExpression String to search for
102 * @param searchSpecBundle SearchSpec bundle
103 * @param callback {@link AppSearchResult}&lt;{@link Bundle}&gt; of performing this
104 * operation.
105 */
106 void globalQuery(
107 in String queryExpression,
108 in Bundle searchSpecBundle,
109 in IAppSearchResultCallback callback);
110
111 /**
Alexander Dorokhined48f2362020-10-20 17:40:49 -0700112 * Fetches the next page of results of a previously executed query. Results can be empty if
113 * next-page token is invalid or all pages have been returned.
114 *
115 * @param nextPageToken The token of pre-loaded results of previously executed query.
116 * @param callback {@link AppSearchResult}&lt;{@link Bundle}&gt; of performing this
117 * operation.
118 */
119 void getNextPage(in long nextPageToken, in IAppSearchResultCallback callback);
120
121 /**
122 * Invalidates the next-page token so that no more results of the related query can be returned.
123 *
124 * @param nextPageToken The token of pre-loaded results of previously executed query to be
125 * Invalidated.
126 */
127 void invalidateNextPageToken(in long nextPageToken);
Alexander Dorokhinef6c66ae2020-03-09 14:47:25 -0700128
129 /**
Terry Wang26b9e5c2020-10-23 02:05:01 -0700130 * Removes documents by URI.
Alexander Dorokhineff82fba2020-03-09 16:35:24 -0700131 *
Terry Wang6413aee2020-10-07 03:04:58 -0700132 * @param databaseName The databaseName the document is in.
133 * @param namespace Namespace of the document to remove.
Alexander Dorokhineff82fba2020-03-09 16:35:24 -0700134 * @param uris The URIs of the documents to delete
135 * @param callback
Terry Wangdbd1dca2020-11-03 17:03:56 -0800136 * If the call fails to start, {@link IAppSearchBatchResultCallback#onSystemError}
137 * will be called with the cause throwable. Otherwise,
138 * {@link IAppSearchBatchResultCallback#onResult} will be called with an
Alexander Dorokhineff82fba2020-03-09 16:35:24 -0700139 * {@link AppSearchBatchResult}&lt;{@link String}, {@link Void}&gt;
140 * where the keys are document URIs. If a document doesn't exist, it will be reported as a
141 * failure where the {@code throwable} is {@code null}.
142 */
Terry Wang26b9e5c2020-10-23 02:05:01 -0700143 void removeByUri(
Terry Wang6413aee2020-10-07 03:04:58 -0700144 in String databaseName,
145 in String namespace,
146 in List<String> uris,
Terry Wangdbd1dca2020-11-03 17:03:56 -0800147 in IAppSearchBatchResultCallback callback);
Alexander Dorokhineff82fba2020-03-09 16:35:24 -0700148
149 /**
Terry Wang26b9e5c2020-10-23 02:05:01 -0700150 * Removes documents by given query.
Alexander Dorokhine7f46d6f2020-04-14 14:40:21 -0700151 *
Terry Wang26b9e5c2020-10-23 02:05:01 -0700152 * @param databaseName The databaseName this query for.
153 * @param queryExpression String to search for
154 * @param searchSpecBundle SearchSpec bundle
Alexander Dorokhine178366b2020-10-20 17:40:49 -0700155 * @param callback {@link IAppSearchResultCallback#onResult} will be called with an
156 * {@link AppSearchResult}&lt;{@link Void}&gt;.
Alexander Dorokhine7f46d6f2020-04-14 14:40:21 -0700157 */
Terry Wang26b9e5c2020-10-23 02:05:01 -0700158 void removeByQuery(
Terry Wang6413aee2020-10-07 03:04:58 -0700159 in String databaseName,
Terry Wang26b9e5c2020-10-23 02:05:01 -0700160 in String queryExpression,
161 in Bundle searchSpecBundle,
Alexander Dorokhine178366b2020-10-20 17:40:49 -0700162 in IAppSearchResultCallback callback);
Terry Wangdbd1dca2020-11-03 17:03:56 -0800163
164 /**
165 * Creates and initializes AppSearchImpl for the calling app.
166 *
167 * @param callback {@link IAppSearchResultCallback#onResult} will be called with an
168 * {@link AppSearchResult}&lt;{@link Void}&gt;.
169 */
170 void initialize(in IAppSearchResultCallback callback);
Terry Wangfebbead2019-10-17 17:05:18 -0700171}