1 // Copyright 2010 Google Inc. All Rights Reserved.
3 package com
.google
.appengine
.api
.search
;
5 import java
.util
.concurrent
.Future
;
8 * The SearchService is used to list available indexes, which can be
9 * queried about their metadata or have index/delete/search operations
10 * performed on them. For example:
13 * SearchService searchService = SearchServiceFactory.getSearchService();
14 * List<Index> indexes = searchService.listIndexes();
15 * for (Index index : indexes) {
17 * index.getNamespace();
18 * index.getConsistency();
19 * index.search("query");
23 * SearchService is also responsible for creating new indexes. For
27 * SearchService searchService = SearchServiceFactory.getSearchService();
28 * Index index = searchService.getIndex(IndexSpec.newBuilder().setName("myindex"));
32 public interface SearchService
{
35 * Returns an instance of {@link Index} corresponding to the provided
38 * @return an instance of {@link Index} corresponding to the given
41 public Index
getIndex(IndexSpec spec
);
44 * Returns an instance of {@link Index} corresponding to the
45 * specification built from the given {@code builder}.
47 * @return an instance of {@link Index} corresponding to the given
50 public Index
getIndex(IndexSpec
.Builder builder
);
53 * Returns the namespace associated with this search service. Each
54 * service instance is assigned one namespace and all operations,
55 * such as listing documents, indexes inherit it. Also, when you
56 * fetch an index, the namespace of this service is passed to the
59 * @return the namespace associated with this search service.
61 public String
getNamespace();
64 * Lists the indexes available. The following code fragment shows how
65 * to list the schemas of each available {@link Index}.
68 * // Get the SearchService for the default namespace
69 * SearchService searchService = SearchServiceFactory.newSearchService();
71 * // List the first page of indexes available and retrieve schemas
72 * ListIndexesResponse response = searchService.listIndexes(
73 * ListIndexesRequest.newBuilder().setSchemaFetched(true).build());
75 * // List out elements of Schema
76 * for (Index index : response) {
77 * String name = index.getName();
78 * Schema schema = index.getSchema();
79 * for (String fieldName : schema.getFieldNames()) {
80 * List<FieldType> typesForField = schema.getFieldTypes(fieldName);
85 * @param request a request specifying which indexes to list
86 * @return a {@link ListIndexesResponse} containing list of existing indexes
87 * @throws ListIndexesException if there is a failure in the search service
90 public ListIndexesResponse
listIndexes(ListIndexesRequest request
);
93 * Lists the indexes available asynchronously.
95 * @param request a request specifying which indexes to list
96 * @return a {@link Future} that will allow getting a
97 * {@link ListIndexesResponse} containing a list of existing indexes
99 public Future
<ListIndexesResponse
> listIndexesAsync(ListIndexesRequest request
);