|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
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(
IndexSpec.newBuilder().setIndexName("indexName"));
// Create a document.
Document document = Document.newBuilder()
.setId("documentId")
.addField(Field.newBuilder().setName("subject").setText("my first email"))
.addField(Field.newBuilder().setName("body")
.setHTML("<html>some content here</html>")
.build();
// Put the document.
try {
index.put(document);
} catch (PutException e) {
if (StatusCode.TRANSIENT_ERROR.equals(e.getOperationResult().getCode())) {
// retry putting document
}
}
// Query the index.
try {
Results<ScoredDocument> results =
index.search(Query.newBuilder().build("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 Summary | |
|---|---|
AddResponse |
add(Document... documents)
Deprecated. as of 1.7.3. Use put(Document...) instead |
AddResponse |
add(Document.Builder... builders)
Deprecated. as of 1.7.3. Use put(Document.Builder...) instead |
AddResponse |
add(java.lang.Iterable<Document> documents)
Deprecated. as of 1.7.3. Use #put(Iterable instead |
java.util.concurrent.Future<AddResponse> |
addAsync(Document... document)
Deprecated. as of 1.7.3. Use putAsync(Document...) instead |
java.util.concurrent.Future<AddResponse> |
addAsync(Document.Builder... document)
Deprecated. as of 1.7.3. Use putAsync(Document.Builder...) instead |
java.util.concurrent.Future<AddResponse> |
addAsync(java.lang.Iterable<Document> documents)
Deprecated. as of 1.7.3. Use #putAsync(Iterable instead |
void |
delete(java.lang.Iterable<java.lang.String> documentIds)
|
void |
delete(java.lang.String... documentIds)
Delete documents for the given document ids from the index if they are in the index. |
java.util.concurrent.Future<java.lang.Void> |
deleteAsync(java.lang.Iterable<java.lang.String> documentIds)
|
java.util.concurrent.Future<java.lang.Void> |
deleteAsync(java.lang.String... documentId)
|
Document |
get(java.lang.String documentId)
Gets a Document for the given document Id. |
Consistency |
getConsistency()
Deprecated. As of 1.7.3 Consistency is deprecated since only PER_DOCUMENT mode is supported |
java.lang.String |
getName()
|
java.lang.String |
getNamespace()
|
GetResponse<Document> |
getRange(GetRequest.Builder builder)
|
GetResponse<Document> |
getRange(GetRequest request)
Get an index's documents, in document Id order. |
java.util.concurrent.Future<GetResponse<Document>> |
getRangeAsync(GetRequest.Builder builder)
|
java.util.concurrent.Future<GetResponse<Document>> |
getRangeAsync(GetRequest request)
|
Schema |
getSchema()
|
ListResponse<Document> |
listDocuments(ListRequest request)
Deprecated. as of 1.7.3. Use getRange(GetRequest) instead. |
java.util.concurrent.Future<ListResponse<Document>> |
listDocumentsAsync(ListRequest request)
Deprecated. as of 1.7.3. Use getRangeAsync(GetRequest) |
PutResponse |
put(Document... documents)
Put the documents into the index, updating any document that is already present. |
PutResponse |
put(Document.Builder... builders)
|
PutResponse |
put(java.lang.Iterable<Document> documents)
|
java.util.concurrent.Future<PutResponse> |
putAsync(Document... document)
|
java.util.concurrent.Future<PutResponse> |
putAsync(Document.Builder... document)
|
java.util.concurrent.Future<PutResponse> |
putAsync(java.lang.Iterable<Document> documents)
|
void |
remove(java.lang.Iterable<java.lang.String> documentIds)
Deprecated. as of 1.7.3. Use #delete(Iterable instead |
void |
remove(java.lang.String... documentIds)
Deprecated. as of 1.7.3. Use delete(String...) instead |
java.util.concurrent.Future<java.lang.Void> |
removeAsync(java.lang.Iterable<java.lang.String> documentIds)
Deprecated. as of 1.7.3. Use #deleteAsync(Iterable instead |
java.util.concurrent.Future<java.lang.Void> |
removeAsync(java.lang.String... documentId)
Deprecated. as of 1.7.3. Use deleteAsync(String...) instead |
Results<ScoredDocument> |
search(Query query)
Search the index for documents matching the query. |
Results<ScoredDocument> |
search(java.lang.String query)
|
java.util.concurrent.Future<Results<ScoredDocument>> |
searchAsync(Query query)
|
java.util.concurrent.Future<Results<ScoredDocument>> |
searchAsync(java.lang.String query)
|
| Method Detail |
|---|
java.lang.String getName()
java.lang.String getNamespace()
@Deprecated Consistency getConsistency()
@Deprecated java.util.concurrent.Future<java.lang.Void> removeAsync(java.lang.String... documentId)
deleteAsync(String...) instead
delete(String...)@Deprecated java.util.concurrent.Future<java.lang.Void> removeAsync(java.lang.Iterable<java.lang.String> documentIds)
#deleteAsync(Iterable) instead
delete(String...)java.util.concurrent.Future<java.lang.Void> deleteAsync(java.lang.String... documentId)
delete(String...)java.util.concurrent.Future<java.lang.Void> deleteAsync(java.lang.Iterable<java.lang.String> documentIds)
delete(String...)@Deprecated java.util.concurrent.Future<AddResponse> addAsync(Document... document)
putAsync(Document...) instead
put(Document...)@Deprecated java.util.concurrent.Future<AddResponse> addAsync(Document.Builder... document)
putAsync(Document.Builder...) instead
put(Document...)@Deprecated java.util.concurrent.Future<AddResponse> addAsync(java.lang.Iterable<Document> documents)
#putAsync(Iterable) instead
put(Document...)java.util.concurrent.Future<PutResponse> putAsync(Document... document)
put(Document...)java.util.concurrent.Future<PutResponse> putAsync(Document.Builder... document)
put(Document...)java.util.concurrent.Future<PutResponse> putAsync(java.lang.Iterable<Document> documents)
put(Document...)java.util.concurrent.Future<Results<ScoredDocument>> searchAsync(java.lang.String query)
search(String)java.util.concurrent.Future<Results<ScoredDocument>> searchAsync(Query query)
search(Query)@Deprecated java.util.concurrent.Future<ListResponse<Document>> listDocumentsAsync(ListRequest request)
getRangeAsync(GetRequest)
listDocuments(ListRequest)java.util.concurrent.Future<GetResponse<Document>> getRangeAsync(GetRequest request)
getRange(GetRequest)java.util.concurrent.Future<GetResponse<Document>> getRangeAsync(GetRequest.Builder builder)
getRange(GetRequest)@Deprecated void remove(java.lang.String... documentIds)
delete(String...) instead
documentIds - the ids of documents to remove
RemoveException - if there is a failure in the search
service deleting documents
java.lang.IllegalArgumentException - if some document id is invalid@Deprecated void remove(java.lang.Iterable<java.lang.String> documentIds)
#delete(Iterable) instead
delete(String...)void delete(java.lang.String... documentIds)
documentIds - the ids of documents to delete
RemoveException - if there is a failure in the search
service deleting documents
java.lang.IllegalArgumentException - if some document id is invalidvoid delete(java.lang.Iterable<java.lang.String> documentIds)
delete(String...)@Deprecated AddResponse add(Document... documents)
put(Document...) instead
documents - the documents to add to the index
AddResponse containing the result of
the add operations indicating success or failure as well as the document
ids. The search service will allocate document ids for documents which
have none provided
AddException - if there is a failure in the search
service adding documents
java.lang.IllegalArgumentException - if some document is invalid or
more than IndexChecker.MAXIMUM_DOCS_PER_REQUEST documents
requested to be added@Deprecated AddResponse add(Document.Builder... builders)
put(Document.Builder...) instead
put(Document...)@Deprecated AddResponse add(java.lang.Iterable<Document> documents)
#put(Iterable) instead
put(Document...)PutResponse put(Document... documents)
documents - the documents to put into the index
AddResponse containing the result of
the put operations indicating success or failure as well as the document
ids. The search service will allocate document ids for documents which
have none provided
PutException - if there is a failure in the search
service putting documents
java.lang.IllegalArgumentException - if some document is invalid or
more than IndexChecker.MAXIMUM_DOCS_PER_REQUEST documents
requested to be put into the indexPutResponse put(Document.Builder... builders)
put(Document...)PutResponse put(java.lang.Iterable<Document> documents)
put(Document...)Document get(java.lang.String documentId)
Document for the given document Id.
documentId - the identifier for the document to retrieve
Document. can be nullResults<ScoredDocument> search(java.lang.String query)
search(Query)Results<ScoredDocument> search(Query query)
query - the fully specified Query object
Results containing
ScoredDocuments
java.lang.IllegalArgumentException - if the query is invalid
SearchQueryException - if the query string is invalid
SearchException - if there is a failure in the search service
performing the search@Deprecated ListResponse<Document> listDocuments(ListRequest request)
getRange(GetRequest) instead.
request - contains various options restricting which documents are
returned.
ListResponse containing a list of
documents from the index
java.lang.IllegalArgumentException - if the list request is invalidGetResponse<Document> getRange(GetRequest request)
request - contains various options restricting which documents are
returned.
GetResponse containing a list of
documents from the index
java.lang.IllegalArgumentException - if the get request is invalidGetResponse<Document> getRange(GetRequest.Builder builder)
getRange(GetRequest)Schema getSchema()
Schema describing supported document field names and
Field.FieldTypes supported for those field names. This schema
will only be populated if the GetIndexesRequest.isSchemaFetched()
is set to true on an SearchService.getIndexes(com.google.appengine.api.search.GetIndexesRequest) request
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||