You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/11/24 15:40:54 UTC

[9/9] incubator-usergrid git commit: Fix merge issue.

Fix merge issue.


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/32276938
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/32276938
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/32276938

Branch: refs/heads/two-dot-o-events
Commit: 32276938d6a4ea986a15fa7bc7c2970a2a83ce41
Parents: c69f0ec
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Nov 24 09:40:22 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Nov 24 09:40:22 2014 -0500

----------------------------------------------------------------------
 .../index/impl/EsEntityIndexImpl.java           |  17 ++-
 .../persistence/index/impl/IndexingUtils.java   | 115 ++++++++++---------
 2 files changed, 67 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/32276938/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 53aaf54..aa797e2 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -51,7 +51,6 @@ import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.index.query.TermQueryBuilder;
 import org.elasticsearch.indices.IndexAlreadyExistsException;
 import org.elasticsearch.indices.IndexMissingException;
-import org.elasticsearch.rest.RestStatus;
 import org.elasticsearch.search.SearchHit;
 import org.elasticsearch.search.SearchHits;
 import org.elasticsearch.search.sort.FieldSortBuilder;
@@ -72,7 +71,6 @@ import org.apache.usergrid.persistence.index.exceptions.IndexException;
 import org.apache.usergrid.persistence.index.query.CandidateResult;
 import org.apache.usergrid.persistence.index.query.CandidateResults;
 import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
@@ -82,6 +80,7 @@ import com.google.inject.Inject;
 import com.google.inject.assistedinject.Assisted;
 
 import static org.apache.usergrid.persistence.index.impl.IndexingUtils.BOOLEAN_PREFIX;
+import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ENTITYID_ID_FIELDNAME;
 import static org.apache.usergrid.persistence.index.impl.IndexingUtils.NUMBER_PREFIX;
 import static org.apache.usergrid.persistence.index.impl.IndexingUtils.SPLITTER;
 import static org.apache.usergrid.persistence.index.impl.IndexingUtils.STRING_PREFIX;
@@ -462,8 +461,7 @@ public class EsEntityIndexImpl implements EntityIndex {
     public void deleteAllVersionsOfEntity( Id entityId ) {
 
         final TermQueryBuilder tqb =
-                QueryBuilders.termQuery( ENTITY_ID_FIELDNAME, entityId.getUuid().toString().toLowerCase() );
-
+                QueryBuilders.termQuery( ENTITYID_ID_FIELDNAME, entityId.getUuid().toString().toLowerCase() );
 
         final DeleteByQueryResponse response =
                 esProvider.getClient().prepareDeleteByQuery( indexName ).setQuery( tqb ).execute().actionGet();
@@ -481,9 +479,8 @@ public class EsEntityIndexImpl implements EntityIndex {
     public void deletePreviousVersions( final Id id, final UUID version ) {
 
         final FilteredQueryBuilder fqb = QueryBuilders.filteredQuery(
-                QueryBuilders.termQuery( ENTITY_ID_FIELDNAME, id.getUuid().toString().toLowerCase() ),
-
-                FilterBuilders.rangeFilter( ENTITY_VERSION_FIELDNAME ).lt( version.timestamp() ) );
+            QueryBuilders.termQuery( IndexingUtils.ENTITYID_ID_FIELDNAME, id.getUuid().toString().toLowerCase() ),
+            FilterBuilders.rangeFilter( IndexingUtils.ENTITY_VERSION_FIELDNAME ).lt( version.timestamp() ) );
 
         final DeleteByQueryResponse response =
                 esProvider.getClient().prepareDeleteByQuery( indexName ).setQuery( fqb ).execute().actionGet();
@@ -507,9 +504,9 @@ public class EsEntityIndexImpl implements EntityIndex {
 
             for ( ShardOperationFailedException failedException : failures ) {
                 throw new IndexException( String.format(
-                        "Unable to delete by query %s.  Failed with code %d and reason %s on shard %s in index %s",
-                        query.toString(), failedException.status(), failedException.reason(), failedException.shardId(),
-                        failedException.index() ) );
+                    "Unable to delete by query %s.  Failed with code %d and reason %s on shard %s in index %s",
+                    query.toString(), failedException.status(), failedException.reason(), failedException.shardId(),
+                    failedException.index() ) );
             }
 
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/32276938/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
index 30b05e4..b26ca62 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
@@ -41,14 +41,17 @@ public class IndexingUtils {
     // These are not allowed in document type names: _ . , | #
     public static final String SEPARATOR = "__";
 
-    /**
-     * Reserved UG fields.
-     */
+    
+    //
+    // Reserved UG fields.
+    //
 
     public static final String ENTITY_CONTEXT_FIELDNAME = "ug_context";
 
     public static final String ENTITYID_ID_FIELDNAME = "ug_entityId";
 
+    public static final String ENTITY_VERSION_FIELDNAME = "ug_entityVersion";
+
 
     /**
       * Create our sub scope.  This is the ownerUUID + type
@@ -155,73 +158,75 @@ public class IndexingUtils {
                         // we need most specific mappings first since it's a stop on match algorithm
 
                         .startObject()
-                        .startObject( "entity_id_template" )
-                            .field( "match", IndexingUtils.ENTITY_ID_FIELDNAME )
-                                 .field( "match_mapping_type", "string" )
-                                        .startObject( "mapping" ).field( "type", "string" )
-                                             .field( "index", "not_analyzed" )
-                                        .endObject()
-                                 .endObject()
-                             .endObject()
-
-                        .startObject()
-                        .startObject( "entity_context_template" )
-                            .field( "match", IndexingUtils.ENTITY_CONTEXT_FIELDNAME )
-                            .field( "match_mapping_type", "string" )
-                                .startObject( "mapping" )
-                                    .field( "type", "string" )
-                                    .field( "index", "not_analyzed" ).endObject()
-                                .endObject()
-                         .endObject()
 
-                         .startObject()
-                           .startObject( "entity_version_template" )
-                               .field( "match", IndexingUtils.ENTITY_VERSION_FIELDNAME )
+                            .startObject( "entity_id_template" )
+                                .field( "match", IndexingUtils.ENTITYID_ID_FIELDNAME )
                                     .field( "match_mapping_type", "string" )
-                                           .startObject( "mapping" ).field( "type", "long" )
-                                           .endObject()
+                                            .startObject( "mapping" ).field( "type", "string" )
+                                                .field( "index", "not_analyzed" )
+                                            .endObject()
                                     .endObject()
                                 .endObject()
 
-                        // any string with field name that starts with sa_ gets analyzed
-                        .startObject()
-                            .startObject( "template_1" )
-                                .field( "match", ANALYZED_STRING_PREFIX + "*" )
-                                .field( "match_mapping_type", "string" ).startObject( "mapping" )
-                                .field( "type", "string" )
-                                .field( "index", "analyzed" )
+                            .startObject()
+                            .startObject( "entity_context_template" )
+                                .field( "match", IndexingUtils.ENTITY_CONTEXT_FIELDNAME )
+                                .field( "match_mapping_type", "string" )
+                                    .startObject( "mapping" )
+                                        .field( "type", "string" )
+                                        .field( "index", "not_analyzed" ).endObject()
+                                    .endObject()
                             .endObject()
-                        .endObject()
-                    .endObject()
-
-                    // all other strings are not analyzed
-                    .startObject()
-                        .startObject( "template_2" )
-                            //todo, should be string prefix, remove 2 field mapping
-                            .field( "match", "*" )
-                            .field( "match_mapping_type", "string" )
-                            .startObject( "mapping" )
-                                .field( "type", "string" )
-                                    .field( "index", "not_analyzed" )
+
+                            .startObject()
+                            .startObject( "entity_version_template" )
+                                .field( "match", IndexingUtils.ENTITY_VERSION_FIELDNAME )
+                                        .field( "match_mapping_type", "string" )
+                                            .startObject( "mapping" ).field( "type", "long" )
+                                            .endObject()
+                                        .endObject()
+                                    .endObject()
+
+                            // any string with field name that starts with sa_ gets analyzed
+                            .startObject()
+                                .startObject( "template_1" )
+                                    .field( "match", ANALYZED_STRING_PREFIX + "*" )
+                                    .field( "match_mapping_type", "string" ).startObject( "mapping" )
+                                    .field( "type", "string" )
+                                    .field( "index", "analyzed" )
+                                .endObject()
                             .endObject()
+
                         .endObject()
-                    .endObject()
 
-                    // fields names starting with go_ get geo-indexed
-                    .startObject()
-                        .startObject( "template_3" )
-                            .field( "match", GEO_PREFIX + "location" )
+                        // all other strings are not analyzed
+                        .startObject()
+                            .startObject( "template_2" )
+                                //todo, should be string prefix, remove 2 field mapping
+                                .field( "match", "*" )
+                                .field( "match_mapping_type", "string" )
                                 .startObject( "mapping" )
-                                    .field( "type", "geo_point" )
+                                    .field( "type", "string" )
+                                        .field( "index", "not_analyzed" )
                                 .endObject()
+                            .endObject()
+                        .endObject()
+
+                        // fields names starting with go_ get geo-indexed
+                        .startObject()
+                            .startObject( "template_3" )
+                                .field( "match", GEO_PREFIX + "location" )
+                                    .startObject( "mapping" )
+                                        .field( "type", "geo_point" )
+                                    .endObject()
+                            .endObject()
                         .endObject()
-                    .endObject()
 
-                .endArray()
+                    .endArray()
 
-            .endObject()
+                .endObject()
 
-        .endObject();
+            .endObject();
 
         return builder;
     }