Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / search / Consistency.java
blobb467740a51a95be13f90366e030aeea533452017
1 // Copyright 2010 Google Inc. All Rights Reserved.
2 package com.google.appengine.api.search;
4 /**
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 {
23 /**
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),
29 /**
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() {
42 return consistency;
45 static Consistency fromProto(SearchServicePb.IndexSpec.Consistency consistency) {
46 return consistency.equals(SearchServicePb.IndexSpec.Consistency.GLOBAL)
47 ? GLOBAL : PER_DOCUMENT;