|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
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.getSearchService();
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.getSearchService();
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 |
|---|
Index getIndex(IndexSpec spec)
Index corresponding to the provided
specification.
Index corresponding to the given
specIndex getIndex(IndexSpec.Builder builder)
Index corresponding to the
specification built from the given builder.
Index corresponding to the given
specjava.lang.String getNamespace()
ListIndexesResponse listIndexes(ListIndexesRequest request)
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);
}
}
request - a request specifying which indexes to list
ListIndexesResponse containing list of existing indexes
ListIndexesException - if there is a failure in the search service
listing indexesjava.util.concurrent.Future<ListIndexesResponse> listIndexesAsync(ListIndexesRequest request)
request - a request specifying which indexes to list
Future that will allow getting a
ListIndexesResponse containing a list of existing indexes
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||