• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.google.android.icing;
2 
3 import com.google.android.icing.proto.DebugInfoResultProto;
4 import com.google.android.icing.proto.DebugInfoVerbosity;
5 import com.google.android.icing.proto.DeleteByNamespaceResultProto;
6 import com.google.android.icing.proto.DeleteByQueryResultProto;
7 import com.google.android.icing.proto.DeleteBySchemaTypeResultProto;
8 import com.google.android.icing.proto.DeleteResultProto;
9 import com.google.android.icing.proto.DocumentProto;
10 import com.google.android.icing.proto.GetAllNamespacesResultProto;
11 import com.google.android.icing.proto.GetOptimizeInfoResultProto;
12 import com.google.android.icing.proto.GetResultProto;
13 import com.google.android.icing.proto.GetResultSpecProto;
14 import com.google.android.icing.proto.GetSchemaResultProto;
15 import com.google.android.icing.proto.GetSchemaTypeResultProto;
16 import com.google.android.icing.proto.InitializeResultProto;
17 import com.google.android.icing.proto.OptimizeResultProto;
18 import com.google.android.icing.proto.PersistToDiskResultProto;
19 import com.google.android.icing.proto.PersistType;
20 import com.google.android.icing.proto.PutResultProto;
21 import com.google.android.icing.proto.ReportUsageResultProto;
22 import com.google.android.icing.proto.ResetResultProto;
23 import com.google.android.icing.proto.ResultSpecProto;
24 import com.google.android.icing.proto.SchemaProto;
25 import com.google.android.icing.proto.ScoringSpecProto;
26 import com.google.android.icing.proto.SearchResultProto;
27 import com.google.android.icing.proto.SearchSpecProto;
28 import com.google.android.icing.proto.SetSchemaResultProto;
29 import com.google.android.icing.proto.StorageInfoResultProto;
30 import com.google.android.icing.proto.SuggestionResponse;
31 import com.google.android.icing.proto.SuggestionSpecProto;
32 import com.google.android.icing.proto.UsageReport;
33 import java.io.Closeable;
34 
35 /** A common user-facing interface to expose the funcationalities provided by Icing Library. */
36 public interface IcingSearchEngineInterface extends Closeable {
37   /**
38    * Initializes the current IcingSearchEngine implementation.
39    *
40    * <p>Internally the icing instance will be initialized.
41    */
initialize()42   InitializeResultProto initialize();
43 
44   /** Sets the schema for the icing instance. */
setSchema(SchemaProto schema)45   SetSchemaResultProto setSchema(SchemaProto schema);
46 
47   /**
48    * Sets the schema for the icing instance.
49    *
50    * @param ignoreErrorsAndDeleteDocuments force to set the schema and delete documents in case of
51    *     incompatible schema change.
52    */
setSchema(SchemaProto schema, boolean ignoreErrorsAndDeleteDocuments)53   SetSchemaResultProto setSchema(SchemaProto schema, boolean ignoreErrorsAndDeleteDocuments);
54 
55   /** Gets the schema for the icing instance. */
getSchema()56   GetSchemaResultProto getSchema();
57 
58   /**
59    * Gets the schema for the icing instance.
60    *
61    * @param schemaType type of the schema.
62    */
getSchemaType(String schemaType)63   GetSchemaTypeResultProto getSchemaType(String schemaType);
64 
65   /** Puts the document. */
put(DocumentProto document)66   PutResultProto put(DocumentProto document);
67 
68   /**
69    * Gets the document.
70    *
71    * @param namespace namespace of the document.
72    * @param uri uri of the document.
73    * @param getResultSpec the spec for getting the document.
74    */
get(String namespace, String uri, GetResultSpecProto getResultSpec)75   GetResultProto get(String namespace, String uri, GetResultSpecProto getResultSpec);
76 
77   /** Reports usage. */
reportUsage(UsageReport usageReport)78   ReportUsageResultProto reportUsage(UsageReport usageReport);
79 
80   /** Gets all namespaces. */
getAllNamespaces()81   GetAllNamespacesResultProto getAllNamespaces();
82 
83   /**
84    * Searches over the documents.
85    *
86    * <p>Documents need to be retrieved on the following {@link #getNextPage} calls on the returned
87    * {@link SearchResultProto}.
88    */
search( SearchSpecProto searchSpec, ScoringSpecProto scoringSpec, ResultSpecProto resultSpec)89   SearchResultProto search(
90       SearchSpecProto searchSpec, ScoringSpecProto scoringSpec, ResultSpecProto resultSpec);
91 
92   /** Gets the next page. */
getNextPage(long nextPageToken)93   SearchResultProto getNextPage(long nextPageToken);
94 
95   /** Invalidates the next page token. */
invalidateNextPageToken(long nextPageToken)96   void invalidateNextPageToken(long nextPageToken);
97 
98   /**
99    * Deletes the document.
100    *
101    * @param namespace the namespace the document to be deleted belong to.
102    * @param uri the uri for the document to be deleted.
103    */
delete(String namespace, String uri)104   DeleteResultProto delete(String namespace, String uri);
105 
106   /** Returns the suggestions for the search query. */
searchSuggestions(SuggestionSpecProto suggestionSpec)107   SuggestionResponse searchSuggestions(SuggestionSpecProto suggestionSpec);
108 
109   /** Deletes documents by the namespace. */
deleteByNamespace(String namespace)110   DeleteByNamespaceResultProto deleteByNamespace(String namespace);
111 
112   /** Deletes documents by the schema type. */
deleteBySchemaType(String schemaType)113   DeleteBySchemaTypeResultProto deleteBySchemaType(String schemaType);
114 
115   /** Deletes documents by the search query. */
deleteByQuery(SearchSpecProto searchSpec)116   DeleteByQueryResultProto deleteByQuery(SearchSpecProto searchSpec);
117 
118   /**
119    * Deletes document by the search query
120    *
121    * @param returnDeletedDocumentInfo whether additional information about deleted documents will be
122    *     included in {@link DeleteByQueryResultProto}.
123    */
deleteByQuery( SearchSpecProto searchSpec, boolean returnDeletedDocumentInfo)124   DeleteByQueryResultProto deleteByQuery(
125       SearchSpecProto searchSpec, boolean returnDeletedDocumentInfo);
126 
127   /** Makes sure every update/delete received till this point is flushed to disk. */
persistToDisk(PersistType.Code persistTypeCode)128   PersistToDiskResultProto persistToDisk(PersistType.Code persistTypeCode);
129 
130   /** Makes the icing instance run tasks that are too expensive to be run in real-time. */
optimize()131   OptimizeResultProto optimize();
132 
133   /** Gets information about the optimization. */
getOptimizeInfo()134   GetOptimizeInfoResultProto getOptimizeInfo();
135 
136   /** Gets information about the storage. */
getStorageInfo()137   StorageInfoResultProto getStorageInfo();
138 
139   /** Gets the debug information for the current icing instance. */
getDebugInfo(DebugInfoVerbosity.Code verbosity)140   DebugInfoResultProto getDebugInfo(DebugInfoVerbosity.Code verbosity);
141 
142   /** Clears all data from the current icing instance, and reinitializes it. */
reset()143   ResetResultProto reset();
144 
145   /** Closes the current icing instance. */
146   @Override
close()147   void close();
148 }
149