1 package com.google.android.icing; 2 3 import com.google.android.icing.proto.BatchGetResultProto; 4 import com.google.android.icing.proto.BatchPutResultProto; 5 import com.google.android.icing.proto.BlobProto; 6 import com.google.android.icing.proto.DebugInfoResultProto; 7 import com.google.android.icing.proto.DebugInfoVerbosity; 8 import com.google.android.icing.proto.DeleteByNamespaceResultProto; 9 import com.google.android.icing.proto.DeleteByQueryResultProto; 10 import com.google.android.icing.proto.DeleteBySchemaTypeResultProto; 11 import com.google.android.icing.proto.DeleteResultProto; 12 import com.google.android.icing.proto.DocumentProto; 13 import com.google.android.icing.proto.GetAllNamespacesResultProto; 14 import com.google.android.icing.proto.GetOptimizeInfoResultProto; 15 import com.google.android.icing.proto.GetResultProto; 16 import com.google.android.icing.proto.GetResultSpecProto; 17 import com.google.android.icing.proto.GetSchemaResultProto; 18 import com.google.android.icing.proto.GetSchemaTypeResultProto; 19 import com.google.android.icing.proto.InitializeResultProto; 20 import com.google.android.icing.proto.OptimizeResultProto; 21 import com.google.android.icing.proto.PersistToDiskResultProto; 22 import com.google.android.icing.proto.PersistType; 23 import com.google.android.icing.proto.PropertyProto; 24 import com.google.android.icing.proto.PutDocumentRequest; 25 import com.google.android.icing.proto.PutResultProto; 26 import com.google.android.icing.proto.ReportUsageResultProto; 27 import com.google.android.icing.proto.ResetResultProto; 28 import com.google.android.icing.proto.ResultSpecProto; 29 import com.google.android.icing.proto.SchemaProto; 30 import com.google.android.icing.proto.ScoringSpecProto; 31 import com.google.android.icing.proto.SearchResultProto; 32 import com.google.android.icing.proto.SearchSpecProto; 33 import com.google.android.icing.proto.SetSchemaRequestProto; 34 import com.google.android.icing.proto.SetSchemaResultProto; 35 import com.google.android.icing.proto.StorageInfoResultProto; 36 import com.google.android.icing.proto.SuggestionResponse; 37 import com.google.android.icing.proto.SuggestionSpecProto; 38 import com.google.android.icing.proto.UsageReport; 39 import java.io.Closeable; 40 41 /** A common user-facing interface to expose the functionalities provided by Icing Library. */ 42 public interface IcingSearchEngineInterface extends Closeable { 43 /** 44 * Initializes the current IcingSearchEngine implementation. 45 * 46 * <p>Internally the icing instance will be initialized. 47 */ initialize()48 InitializeResultProto initialize(); 49 50 /** 51 * Sets the schema for the icing instance. 52 * 53 * <p>Note: This method is deprecated. Please use {@link 54 * #setSchemaWithRequestProto(SetSchemaRequestProto)} instead. 55 */ setSchema(SchemaProto schema)56 SetSchemaResultProto setSchema(SchemaProto schema); 57 58 /** 59 * Sets the schema for the icing instance. 60 * 61 * <p>Note: This method is deprecated. Please use {@link 62 * #setSchemaWithRequestProto(SetSchemaRequestProto)} instead. 63 * 64 * @param ignoreErrorsAndDeleteDocuments force to set the schema and delete documents in case of 65 * incompatible schema change. 66 */ setSchema(SchemaProto schema, boolean ignoreErrorsAndDeleteDocuments)67 SetSchemaResultProto setSchema(SchemaProto schema, boolean ignoreErrorsAndDeleteDocuments); 68 69 /** 70 * Sets the schema for the icing instance. 71 * 72 * @param setSchemaRequest the request proto for setting the schema. 73 */ setSchemaWithRequestProto(SetSchemaRequestProto setSchemaRequest)74 SetSchemaResultProto setSchemaWithRequestProto(SetSchemaRequestProto setSchemaRequest); 75 76 /** Gets the schema for the icing instance. */ getSchema()77 GetSchemaResultProto getSchema(); 78 79 /** 80 * Gets the schema for the specified database for the icing instance. 81 * 82 * @param database an icing schema database name. The retrieved SchemaProto will only contain 83 * types that belong to the requested database. 84 */ getSchemaForDatabase(String database)85 GetSchemaResultProto getSchemaForDatabase(String database); 86 87 /** 88 * Gets the schema for the icing instance. 89 * 90 * @param schemaType type of the schema. 91 */ getSchemaType(String schemaType)92 GetSchemaTypeResultProto getSchemaType(String schemaType); 93 94 /** Puts the document. */ put(DocumentProto document)95 PutResultProto put(DocumentProto document); 96 97 /** Puts a number of documents. */ batchPut(PutDocumentRequest documents)98 BatchPutResultProto batchPut(PutDocumentRequest documents); 99 100 /** 101 * Gets the document. 102 * 103 * @param namespace namespace of the document. 104 * @param uri uri of the document. 105 * @param getResultSpec the spec for getting the document. 106 */ get(String namespace, String uri, GetResultSpecProto getResultSpec)107 GetResultProto get(String namespace, String uri, GetResultSpecProto getResultSpec); 108 109 /** 110 * Gets a list of documents. 111 * 112 * @param getResultSpec the spec for getting the documents. 113 */ batchGet(GetResultSpecProto getResultSpec)114 BatchGetResultProto batchGet(GetResultSpecProto getResultSpec); 115 116 /** Reports usage. */ reportUsage(UsageReport usageReport)117 ReportUsageResultProto reportUsage(UsageReport usageReport); 118 119 /** Gets all namespaces. */ getAllNamespaces()120 GetAllNamespacesResultProto getAllNamespaces(); 121 122 /** 123 * Searches over the documents. 124 * 125 * <p>Documents need to be retrieved on the following {@link #getNextPage} calls on the returned 126 * {@link SearchResultProto}. 127 */ search( SearchSpecProto searchSpec, ScoringSpecProto scoringSpec, ResultSpecProto resultSpec)128 SearchResultProto search( 129 SearchSpecProto searchSpec, ScoringSpecProto scoringSpec, ResultSpecProto resultSpec); 130 131 /** Gets the next page. */ getNextPage(long nextPageToken)132 SearchResultProto getNextPage(long nextPageToken); 133 134 /** Invalidates the next page token. */ invalidateNextPageToken(long nextPageToken)135 void invalidateNextPageToken(long nextPageToken); 136 137 /** Gets a file descriptor to write blob data. */ openWriteBlob(PropertyProto.BlobHandleProto blobHandle)138 BlobProto openWriteBlob(PropertyProto.BlobHandleProto blobHandle); 139 140 /** Removes a pending blob. */ removeBlob(PropertyProto.BlobHandleProto blobHandle)141 BlobProto removeBlob(PropertyProto.BlobHandleProto blobHandle); 142 143 /** Gets a file descriptor to read blob data. */ openReadBlob(PropertyProto.BlobHandleProto blobHandle)144 BlobProto openReadBlob(PropertyProto.BlobHandleProto blobHandle); 145 146 /** Marks the blob is committed. */ commitBlob(PropertyProto.BlobHandleProto blobHandle)147 BlobProto commitBlob(PropertyProto.BlobHandleProto blobHandle); 148 149 /** 150 * Deletes the document. 151 * 152 * @param namespace the namespace the document to be deleted belong to. 153 * @param uri the uri for the document to be deleted. 154 */ delete(String namespace, String uri)155 DeleteResultProto delete(String namespace, String uri); 156 157 /** Returns the suggestions for the search query. */ searchSuggestions(SuggestionSpecProto suggestionSpec)158 SuggestionResponse searchSuggestions(SuggestionSpecProto suggestionSpec); 159 160 /** Deletes documents by the namespace. */ deleteByNamespace(String namespace)161 DeleteByNamespaceResultProto deleteByNamespace(String namespace); 162 163 /** Deletes documents by the schema type. */ deleteBySchemaType(String schemaType)164 DeleteBySchemaTypeResultProto deleteBySchemaType(String schemaType); 165 166 /** Deletes documents by the search query. */ deleteByQuery(SearchSpecProto searchSpec)167 DeleteByQueryResultProto deleteByQuery(SearchSpecProto searchSpec); 168 169 /** 170 * Deletes document by the search query 171 * 172 * @param returnDeletedDocumentInfo whether additional information about deleted documents will be 173 * included in {@link DeleteByQueryResultProto}. 174 */ deleteByQuery( SearchSpecProto searchSpec, boolean returnDeletedDocumentInfo)175 DeleteByQueryResultProto deleteByQuery( 176 SearchSpecProto searchSpec, boolean returnDeletedDocumentInfo); 177 178 /** Makes sure every update/delete received till this point is flushed to disk. */ persistToDisk(PersistType.Code persistTypeCode)179 PersistToDiskResultProto persistToDisk(PersistType.Code persistTypeCode); 180 181 /** Makes the icing instance run tasks that are too expensive to be run in real-time. */ optimize()182 OptimizeResultProto optimize(); 183 184 /** Gets information about the optimization. */ getOptimizeInfo()185 GetOptimizeInfoResultProto getOptimizeInfo(); 186 187 /** Gets information about the storage. */ getStorageInfo()188 StorageInfoResultProto getStorageInfo(); 189 190 /** Gets the debug information for the current icing instance. */ getDebugInfo(DebugInfoVerbosity.Code verbosity)191 DebugInfoResultProto getDebugInfo(DebugInfoVerbosity.Code verbosity); 192 193 /** Clears all data from the current icing instance, and reinitializes it. */ reset()194 ResetResultProto reset(); 195 196 /** Closes the current icing instance. */ 197 @Override close()198 void close(); 199 } 200