Github user michaelarusso commented on a diff in the pull request:
https://github.com/apache/usergrid/pull/497#discussion_r57916698
--- Diff:
stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
---
@@ -146,16 +167,59 @@ public IndexServiceImpl( final GraphManagerFactory
graphManagerFactory, final En
logger.debug("adding edge {} to batch for entity {}",
indexEdge, entity);
}
- batch.index( indexEdge, entity );
+ Optional<Set<String>> fieldsToIndex =
getFilteredStringObjectMap( indexEdge );
+
+ batch.index( indexEdge, entity ,fieldsToIndex);
+
return batch.build();
} );
return ObservableTimer.time( batches, addTimer );
-
}
+ /**
+ * This method takes in an entity and flattens it out then begins the
process to filter out
+ * properties that we do not want to index. Once flatted we parse
through each property
+ * and verify that we want it to be indexed on. The set of default
properties that will always be indexed are as follows.
+ * UUID - TYPE - MODIFIED - CREATED. Depending on the schema this may
change. For instance, users will always require
+ * NAME, but the above four will always be taken in.
+
+ * @param indexEdge
+ * @return This returns a filtered map that contains the flatted
properties of the entity. If there isn't a schema
+ * associated with the collection then return null ( and index the
entity in its entirety )
+ */
+ private Optional<Set<String>> getFilteredStringObjectMap( final
IndexEdge indexEdge ) {
+
+ Id mapOwner = new SimpleId( indexEdge.getNodeId().getUuid(),
TYPE_APPLICATION );
+
+ final MapScope ms = CpNamingUtils.getEntityTypeMapScope( mapOwner
);
+
+ MapManager mm = mapManagerFactory.createMapManager( ms );
+
+ Set<String> defaultProperties;
+ ArrayList fieldsToKeep;
+
+ String collectionName =
CpNamingUtils.getCollectionNameFromEdgeName( indexEdge.getEdgeName() );
+ String jsonSchemaMap = mm.getString( collectionName );
+
+ //If we do have a schema then parse it and add it to a list of
properties we want to keep.Otherwise return.
+ if ( jsonSchemaMap != null ) {
--- End diff --
Seems like this logic is duplicated in a couple classes, lets see if
there's a way to simplify
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---