Index (Google App Engine API for Java)

Interface Index

  • public interface Index
    An Index allows synchronous and asynchronous adding and deleting of Documents as well as synchronous and asynchronous searching for Documents for a given Query. The following code fragment shows how to add documents, then search the index for documents matching a query.

      // Get the SearchService for the default namespace
      SearchService searchService = SearchServiceFactory.getSearchService();
      // Get the index. If not yet created, create it.
      Index index = searchService.getIndex(
      // Create a document.
      Document document = Document.newBuilder()
          .addField(Field.newBuilder().setName("subject").setText("my first email"))
               .setHTML("<html>some content here</html>")
      // Put the document.
      try {
      } catch (PutException e) {
        if (StatusCode.TRANSIENT_ERROR.equals(e.getOperationResult().getCode())) {
          // retry putting document
      // Query the index.
      try {
        Results<ScoredDocument> results =
  "subject:first body:here"));
        // Iterate through the search results.
        for (ScoredDocument document : results) {
          // display results
      } catch (SearchException e) {
        if (StatusCode.TRANSIENT_ERROR.equals(e.getOperationResult().getCode())) {
          // retry
    • Method Detail

      • getName

        java.lang.String getName()
        the name of the index
      • getNamespace

        java.lang.String getNamespace()
        the namespace of the index name
      • deleteAsync

        java.util.concurrent.Future<java.lang.Void> deleteAsync(java.lang.String... documentId)
        See Also:
      • deleteAsync

        java.util.concurrent.Future<java.lang.Void> deleteAsync(java.lang.Iterable<java.lang.String> documentIds)
        See Also:
      • deleteSchemaAsync

        java.util.concurrent.Future<java.lang.Void> deleteSchemaAsync()
        Deprecated. as of 1.7.4
        See Also: