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/12/03 20:59:37 UTC

[27/50] [abbrv] incubator-usergrid git commit: Change ES mappings to omit both the storage of document source and document fields in the index for USERGRID-255.

Change ES mappings to omit both the storage of document source and document fields in the index for USERGRID-255.


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

Branch: refs/heads/no-source-in-es
Commit: 5ba1e7e3a252104981f2e5cf4f5fc4b91205823c
Parents: ce20abe
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Nov 26 16:49:00 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Nov 26 16:49:00 2014 -0500

----------------------------------------------------------------------
 .../persistence/index/impl/IndexingUtils.java   | 112 ++++++++++++-------
 1 file changed, 71 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5ba1e7e3/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 6d34b15..6272dcf 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
@@ -151,69 +151,99 @@ public class IndexingUtils {
 
                 .startObject( type )
 
+                    // don't store source object in ES 
+                    .field("_source") 
+                        .startObject()
+                            .field("_source").startObject().field("enabled", false).endObject()
+                        .endObject()
+
                     .startArray( "dynamic_templates" )
 
                         // we need most specific mappings first since it's a stop on match algorithm
 
-                        .startObject()
-                        .startObject( "context_template" )
-                            .field( "match", IndexingUtils.ENTITYID_ID_FIELDNAME )
-                                 .field( "match_mapping_type", "string" )
-                                        .startObject( "mapping" ).field( "type", "string" )
-                                             .field( "index", "not_analyzed" )
-                                        .endObject()
-                                 .endObject()
-                             .endObject()
+                        .startObject() // array item
+                            .startObject( "context_template" )
+                                .field( "match", IndexingUtils.ENTITYID_ID_FIELDNAME )
+                                .field( "match_mapping_type", "string" )
+                                .startObject( "mapping" )
+                                    .field( "type", "string" )
+                                    .field( "index", "not_analyzed" )
+                                .endObject()
+                                // dont't store field in ES
+                                .field("store", false)
+                            .endObject()
+                        .endObject()
 
-                        .startObject()
-                        .startObject( "context_template" )
-                            .field( "match", IndexingUtils.ENTITY_CONTEXT_FIELDNAME )
-                            .field( "match_mapping_type", "string" )
+                        .startObject() // array item
+
+                            .startObject( "context_template" )
+                                .field( "match", IndexingUtils.ENTITY_CONTEXT_FIELDNAME )
+                                .field( "match_mapping_type", "string" )
                                 .startObject( "mapping" )
                                     .field( "type", "string" )
-                                    .field( "index", "not_analyzed" ).endObject()
+                                    .field( "index", "not_analyzed" )
                                 .endObject()
-                         .endObject()
+                                // dont't store field in ES
+                                .field("store", false)
+                            .endObject()
+
+                        .endObject()
 
                         // any string with field name that starts with sa_ gets analyzed
-                        .startObject()
+
+                        .startObject() // array item
+
                             .startObject( "template_1" )
                                 .field( "match", ANALYZED_STRING_PREFIX + "*" )
-                                .field( "match_mapping_type", "string" ).startObject( "mapping" )
-                                .field( "type", "string" )
-                                .field( "index", "analyzed" )
+                                .field( "match_mapping_type", "string" )
+                                .startObject( "mapping")
+                                    .field( "type", "string" )
+                                    .field( "index", "analyzed" )
+                                .endObject()
+                                // dont't store field in ES
+                                .field("store", false)
                             .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" )
+
+                        // all other strings are not analyzed
+
+                        .startObject() // array item
+
+                            .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" )
+                                .endObject()
+                                // dont't store field in ES
+                                .field("store", false)
                             .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()
+                        // fields names starting with go_ get geo-indexed
+
+                        .startObject() // array item
+
+                            .startObject( "template_3" )
+                                .field( "match", GEO_PREFIX + "location" )
+                                    .startObject( "mapping" )
+                                        .field( "type", "geo_point" )
+                                    .endObject()
+                                // dont't store field in ES
+                                .field("store", false)
+                            .endObject()
+
                         .endObject()
-                    .endObject()
 
-                .endArray()
+                    .endArray()
 
-            .endObject()
+                .endObject()
 
-        .endObject();
+            .endObject();
 
         return builder;
     }