1 // Copyright 2010 Google Inc. All Rights Reserved.
2 package com
.google
.appengine
.api
.search
;
5 * Supported consistency modes by indexes. When creating an index you may
6 * request whether the index is {@link #GLOBAL} or {@link #PER_DOCUMENT}
7 * consistent using this enum. An index with {@link #GLOBAL} consistency, when
8 * searched, returns results with all changes prior to the search request,
9 * committed. For {@link #PER_DOCUMENT} consistent indexes, a search result may
10 * contain some out of date documents. However, any two changes to any document
11 * stored in such an index are applied in the correct order. The benefit of
12 * {@link #PER_DOCUMENT} consistent index is that it provides much higher index
13 * document throughput than a globally consistent one.
15 * <p>Typically, you would use {@link #GLOBAL} consistency if organizing
16 * personal user information, to reflect all changes known to the user in
17 * any search results. The {@link #PER_DOCUMENT} consistency should be used
18 * in indexes that amalgamate information from multiple sources, where no
19 * single user is aware of all collected data.
22 public enum Consistency
{
24 * Globally consistent index, which guarantees that search returns
25 * results including changes submitted before the latest search request.
27 GLOBAL(SearchServicePb
.IndexSpec
.Consistency
.GLOBAL
),
30 * Document level consistent index, with search results that may not include
31 * the latest changes to the index.
33 PER_DOCUMENT(SearchServicePb
.IndexSpec
.Consistency
.PER_DOCUMENT
);
35 private final SearchServicePb
.IndexSpec
.Consistency consistency
;
37 private Consistency(SearchServicePb
.IndexSpec
.Consistency consistency
) {
38 this.consistency
= consistency
;
41 SearchServicePb
.IndexSpec
.Consistency
getConsistency() {
45 static Consistency
fromProto(SearchServicePb
.IndexSpec
.Consistency consistency
) {
46 return consistency
.equals(SearchServicePb
.IndexSpec
.Consistency
.GLOBAL
)
47 ? GLOBAL
: PER_DOCUMENT
;