com.google.appengine.api.search
Interface SearchService


public interface SearchService

The SearchService is used to list available indexes, which can be queried about their metadata or have index/delete/search operations performed on them. For example:

 SearchService searchService = SearchServiceFactory.newSearchService();
 List<Index> indexes = searchService.listIndexes();
 for (Index index : indexes) {
   index.getName();
   index.getNamespace();
   index.getConsistency();
   index.search("query");
 }
 
SearchService is also responsible for creating new indexes. For example:
 SearchService searchService = SearchServiceFactory.newSearchService();
 Index index = searchService.getIndex(IndexSpec.newBuilder().setName("myindex"));
 


Method Summary
 Index getIndex(IndexSpec.Builder builder)
          Returns an instance of Index corresponding to the specification built from the given builder.
 Index getIndex(IndexSpec spec)
          Returns an instance of Index corresponding to the provided specification.
 java.lang.String getNamespace()
          Returns the namespace associated with this search service.
 ListIndexesResponse listIndexes(ListIndexesRequest request)
          Lists the indexes available.
 java.util.concurrent.Future<ListIndexesResponse> listIndexesAsync(ListIndexesRequest request)
          Lists the indexes available asynchronously.
 

Method Detail

getIndex

Index getIndex(IndexSpec spec)
Returns an instance of Index corresponding to the provided specification.

Returns:
an instance of Index corresponding to the given spec

getIndex

Index getIndex(IndexSpec.Builder builder)
Returns an instance of Index corresponding to the specification built from the given builder.

Returns:
an instance of Index corresponding to the given spec

getNamespace

java.lang.String getNamespace()
Returns the namespace associated with this search service. Each service instance is assigned one namespace and all operations, such as listing documents, indexes inherit it. Also, when you fetch an index, the namespace of this service is passed to the returned index.

Returns:
the namespace associated with this search service.

listIndexes

ListIndexesResponse listIndexes(ListIndexesRequest request)
Lists the indexes available. The following code fragment shows how to list the schemas of each available Index.
   // Get the SearchService for the default namespace
   SearchService searchService = SearchServiceFactory.newSearchService();

   // List the first page of indexes available and retrieve schemas 
   ListIndexesResponse response = searchService.listIndexes(
       ListIndexesRequest.newBuilder().setSchemaFetched(true).build());

   // List out elements of Schema
   for (Index index : response) {
     String name = index.getName();
     Schema schema = index.getSchema();
     for (String fieldName : schema.getFieldNames()) {
        List typesForField = schema.getFieldTypes(fieldName);
     }
   }
 

Parameters:
request - a request specifying which indexes to list
Returns:
a ListIndexesResponse containing list of existing indexes
Throws:
ListIndexesException - if there is a failure in the search service listing indexes

listIndexesAsync

java.util.concurrent.Future<ListIndexesResponse> listIndexesAsync(ListIndexesRequest request)
Lists the indexes available asynchronously.

Parameters:
request - a request specifying which indexes to list
Returns:
a Future that will allow getting a ListIndexesResponse containing a list of existing indexes