usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [4/4] incubator-usergrid git commit: WIP overwrite
Date Fri, 10 Apr 2015 00:25:51 GMT
WIP overwrite


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

Branch: refs/heads/USERGRID-536
Commit: 035cb783dbd4facfd7a3475f215e9112a18b4c4f
Parents: b098049
Author: Todd Nine <tnine@apigee.com>
Authored: Thu Apr 9 18:25:45 2015 -0600
Committer: Todd Nine <tnine@apigee.com>
Committed: Thu Apr 9 18:25:45 2015 -0600

----------------------------------------------------------------------
 .../batch/service/SchedulerServiceImpl.java     |   4 +-
 .../corepersistence/CpEntityManager.java        |  17 +-
 .../corepersistence/CpRelationManager.java      | 221 ++-----------------
 .../events/EntityVersionDeletedHandler.java     |  15 +-
 .../results/ElasticSearchQueryExecutor.java     |  40 ++--
 .../org/apache/usergrid/persistence/Query.java  |  70 +++---
 .../apache/usergrid/persistence/QueryUtils.java |  61 ++---
 .../usergrid/persistence/RelationManager.java   |   3 +-
 .../java/org/apache/usergrid/Application.java   |   2 +-
 .../org/apache/usergrid/CoreApplication.java    |   2 +-
 .../usergrid/batch/job/SchedulerRuntime8IT.java |   2 +-
 .../corepersistence/StaleIndexCleanupTest.java  |  15 +-
 .../usergrid/persistence/CollectionIT.java      | 103 ++++-----
 .../apache/usergrid/persistence/CounterIT.java  |   2 +-
 .../usergrid/persistence/CountingMutatorIT.java |   2 +-
 .../persistence/EntityConnectionsIT.java        |   2 +-
 .../usergrid/persistence/EntityManagerIT.java   |   4 +-
 .../org/apache/usergrid/persistence/GeoIT.java  |   2 +-
 .../persistence/GeoQueryBooleanTest.java        |   2 +-
 .../apache/usergrid/persistence/IndexIT.java    |   2 +-
 .../usergrid/persistence/PathQueryIT.java       |   4 +-
 .../PerformanceEntityRebuildIndexTest.java      |   2 +-
 .../usergrid/persistence/PermissionsIT.java     |   2 +-
 .../apache/usergrid/persistence/QueryTest.java  |   6 +-
 .../cassandra/QueryProcessorTest.java           |   2 +-
 .../persistence/query/CollectionIoHelper.java   |   2 +-
 .../persistence/query/ConnectionHelper.java     |   2 +-
 .../query/IntersectionTransitivePagingIT.java   |   2 +-
 .../query/IntersectionUnionPagingIT.java        |   2 +-
 .../usergrid/persistence/query/IoHelper.java    |   2 +-
 .../persistence/query/IteratingQueryIT.java     |   2 +-
 .../persistence/query/NotSubPropertyIT.java     |   2 +-
 .../persistence/index/CandidateResults.java     |   5 +
 .../rest/applications/ServiceResource.java      |  35 +--
 .../usergrid/services/ServiceParameter.java     |   3 +-
 .../usergrid/services/ServiceRequest.java       |   2 +-
 .../usergrid/services/ServiceResults.java       |  38 +---
 37 files changed, 213 insertions(+), 471 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
index f3fab9e..87c1d50 100644
--- a/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
@@ -377,9 +377,7 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
         EntityManager em = emf.getEntityManager( emf.getManagementAppId() );
 
 
-        Query query = new Query();
-        query.addEqualityFilter( JOB_NAME, jobName );
-        query.addEqualityFilter( JOB_ID, jobId );
+        Query query = Query.fromQL( "select * where " + JOB_NAME + " = '" + jobName + "' AND " + JOB_ID + " = " + jobId );
 
         Results r = em.searchCollection( em.getApplicationRef(), "job_stats", query );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index e7159f9..90d4534 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -79,8 +79,10 @@ import org.apache.usergrid.persistence.exceptions.DuplicateUniquePropertyExistsE
 import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
 import org.apache.usergrid.persistence.exceptions.RequiredPropertyNotFoundException;
 import org.apache.usergrid.persistence.exceptions.UnexpectedEntityTypeException;
+import org.apache.usergrid.persistence.graph.Edge;
 import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
 import org.apache.usergrid.persistence.index.EntityIndexBatch;
+import org.apache.usergrid.persistence.index.IndexEdge;
 import org.apache.usergrid.persistence.index.query.CounterResolution;
 import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.persistence.map.MapManager;
@@ -123,7 +125,7 @@ import static me.prettyprint.hector.api.factory.HFactory.createMutator;
 import static org.apache.commons.lang.StringUtils.capitalize;
 import static org.apache.commons.lang.StringUtils.isBlank;
 import static org.apache.usergrid.corepersistence.util.CpEntityMapUtils.entityToCpEntity;
-import static org.apache.usergrid.corepersistence.util.CpNamingUtils.generateScopeFromCollection;
+import static org.apache.usergrid.corepersistence.util.CpNamingUtils.generateScopeFromSource;
 import static org.apache.usergrid.persistence.Schema.COLLECTION_ROLES;
 import static org.apache.usergrid.persistence.Schema.COLLECTION_USERS;
 import static org.apache.usergrid.persistence.Schema.DICTIONARY_PERMISSIONS;
@@ -2697,11 +2699,6 @@ public class CpEntityManager implements EntityManager {
         boolean entityHasDictionary = Schema.getDefaultSchema()
                 .hasDictionary( entity.getType(), dictionaryName );
 
-        // Don't index dynamic dictionaries not defined by the schema
-        if ( entityHasDictionary ) {
-            getRelationManager( entity ).batchUpdateSetIndexes(
-                    batch, dictionaryName, elementValue, removeFromDictionary, timestampUuid );
-        }
 
         ApplicationCF dictionary_cf = entityHasDictionary
                 ? ENTITY_DICTIONARIES : ENTITY_COMPOSITE_DICTIONARIES;
@@ -2876,16 +2873,14 @@ public class CpEntityManager implements EntityManager {
     }
 
 
-    void indexEntityIntoCollection( org.apache.usergrid.persistence.model.entity.Entity collectionEntity,
-                                    org.apache.usergrid.persistence.model.entity.Entity memberEntity,
-                                    String collName ) {
+    void indexEntityIntoCollection( final Edge edge,  final  org.apache.usergrid.persistence.model.entity.Entity collectionMember) {
 
         final ApplicationEntityIndex aie = getManagerCache().getEntityIndex( getApplicationScope() );
         final EntityIndexBatch batch = aie.createBatch();
 
         // index member into entity collection | type scope
-        IndexScope collectionIndexScope = generateScopeFromCollection( collectionEntity.getId(), collName );
-        batch.index( collectionIndexScope, memberEntity );
+        final IndexEdge collectionIndexScope = generateScopeFromSource( edge );
+        batch.index( collectionIndexScope, collectionMember );
 
         //TODO REMOVE INDEX CODE
         //        // index member into entity | all-types scope

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index a3ef1f5..0147740 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -17,7 +17,6 @@
 package org.apache.usergrid.corepersistence;
 
 
-import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -71,7 +70,6 @@ import org.apache.usergrid.persistence.index.IndexEdge;
 import org.apache.usergrid.persistence.index.SearchEdge;
 import org.apache.usergrid.persistence.index.SearchTypes;
 import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.index.query.SortPredicate;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.schema.CollectionInfo;
@@ -80,7 +78,6 @@ import org.apache.usergrid.utils.MapUtils;
 import com.codahale.metrics.Timer;
 import com.google.common.base.Preconditions;
 
-import me.prettyprint.hector.api.mutation.Mutator;
 import rx.Observable;
 import rx.functions.Action1;
 import rx.functions.Func1;
@@ -93,18 +90,12 @@ import static org.apache.usergrid.corepersistence.util.CpNamingUtils.createSearc
 import static org.apache.usergrid.corepersistence.util.CpNamingUtils.generateScopeFromSource;
 import static org.apache.usergrid.corepersistence.util.CpNamingUtils.getNameFromEdgeType;
 import static org.apache.usergrid.persistence.Schema.COLLECTION_ROLES;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_CREATED;
 import static org.apache.usergrid.persistence.Schema.PROPERTY_INACTIVITY;
 import static org.apache.usergrid.persistence.Schema.PROPERTY_NAME;
 import static org.apache.usergrid.persistence.Schema.PROPERTY_TITLE;
-import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
 import static org.apache.usergrid.persistence.Schema.TYPE_ENTITY;
 import static org.apache.usergrid.persistence.Schema.TYPE_ROLE;
 import static org.apache.usergrid.persistence.Schema.getDefaultSchema;
-import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_DICTIONARIES;
-import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_INDEX;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.addInsertToMutator;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.key;
 import static org.apache.usergrid.utils.ClassUtils.cast;
 import static org.apache.usergrid.utils.InflectionUtils.singularize;
 import static org.apache.usergrid.utils.MapUtils.addMapSet;
@@ -574,7 +565,7 @@ public class CpRelationManager implements RelationManager {
             logger.debug( "Wrote edge {}", edge );
         }
 
-        ( ( CpEntityManager ) em ).indexEntityIntoCollection( cpHeadEntity, memberEntity, collName );
+        ( ( CpEntityManager ) em ).indexEntityIntoCollection( edge, memberEntity );
 
         if(logger.isDebugEnabled()) {
             logger.debug( "Added entity {}:{} to collection {}", new Object[] {
@@ -1141,27 +1132,26 @@ public class CpRelationManager implements RelationManager {
             }
         }
 
-        if ( query.isReversed() ) {
+        //TODO T.N. not sure if we still need this.  If we do then we ned to modify our query interface.
 
-            SortPredicate
-            Query.SortPredicate desc =
-                new Query.SortPredicate( PROPERTY_CREATED, Query.SortDirection.DESCENDING );
-
-            try {
-                query.addSort( desc );
-            }
-            catch ( Exception e ) {
-                logger.warn( "Attempted to reverse sort order already set", PROPERTY_CREATED );
-            }
-        }
-
-        if ( query.getSortPredicates().isEmpty() ) {
-
-            Query.SortPredicate asc =
-                new Query.SortPredicate( PROPERTY_CREATED, Query.SortDirection.ASCENDING);
-
-            query.addSort( asc );
-        }
+//        final String ql = query.getQl();
+//
+//        if ( query.isReversed()  && ( StringUtils.isEmpty( ql ) || !(ql.contains( "order by " )) )) {
+//
+//
+//            final String sortQueryString =
+//
+//            SortPredicate
+//            Query.SortPredicate desc =
+//                new Query.SortPredicate( PROPERTY_CREATED, Query.SortDirection.DESCENDING );
+//
+//            try {
+//                query.addSort( desc );
+//            }
+//            catch ( Exception e ) {
+//                logger.warn( "Attempted to reverse sort order already set", PROPERTY_CREATED );
+//            }
+//        }
 
         return query;
     }
@@ -1193,177 +1183,6 @@ public class CpRelationManager implements RelationManager {
         return entity;
     }
 
-//
-//    private Results buildConnectionResults( final IndexScope indexScope,
-//            final Query query, final CandidateResults crs, final String connectionType ) {
-//
-//        if ( query.getLevel().equals( Level.ALL_PROPERTIES ) ) {
-//            return buildResults( indexScope, query, crs, connectionType );
-//        }
-//
-//        final EntityRef sourceRef = new SimpleEntityRef( headEntity.getType(), headEntity.getUuid() );
-//
-//        List<ConnectionRef> refs = new ArrayList<ConnectionRef>( crs.size() );
-//
-//        for ( CandidateResult cr : crs ) {
-//
-//            SimpleEntityRef targetRef =
-//                    new SimpleEntityRef( cr.getId().getType(), cr.getId().getUuid() );
-//
-//            final ConnectionRef ref =
-//                    new ConnectionRefImpl( sourceRef, connectionType, targetRef );
-//
-//            refs.add( ref );
-//        }
-//
-//        return Results.fromConnections( refs );
-//    }
-
-
-
-
-    @Override
-    public void batchUpdateSetIndexes( Mutator<ByteBuffer> batch, String setName, Object elementValue,
-                                       boolean removeFromSet, UUID timestampUuid ) throws Exception {
-
-        Entity entity = getHeadEntity();
-
-        elementValue = getDefaultSchema()
-                .validateEntitySetValue( entity.getType(), setName, elementValue );
-
-        IndexUpdate indexUpdate = batchStartIndexUpdate( batch, entity, setName, elementValue,
-                timestampUuid, true, true, removeFromSet, false );
-
-        // Update collections
-
-        Map<String, Set<CollectionInfo>> containers =
-                getDefaultSchema().getContainersIndexingDictionary( entity.getType(), setName );
-
-        if ( containers != null ) {
-            Map<EntityRef, Set<String>> containerEntities = getContainers();
-            for ( EntityRef containerEntity : containerEntities.keySet() ) {
-                if ( containerEntity.getType().equals( TYPE_APPLICATION )
-                        && Schema.isAssociatedEntityType( entity.getType() ) ) {
-                    logger.debug( "Extended properties for {} not indexed by application", entity.getType() );
-                    continue;
-                }
-                Set<String> collectionNames = containerEntities.get( containerEntity );
-                Set<CollectionInfo> collections = containers.get( containerEntity.getType() );
-
-                if ( collections != null ) {
-
-                    for ( CollectionInfo collection : collections ) {
-                        if ( collectionNames.contains( collection.getName() ) ) {
-                            batchUpdateCollectionIndex( indexUpdate, containerEntity, collection.getName() );
-                        }
-                    }
-                }
-            }
-        }
-
-        batchUpdateBackwardConnectionsDictionaryIndexes( indexUpdate );
-    }
-
-
-    /**
-     * Batch update collection index.
-     *
-     * @param indexUpdate The update to apply
-     * @param owner The entity that is the owner context of this entity update. Can either be an
-     * application, or another * entity
-     * @param collectionName the collection name
-     *
-     * @return The indexUpdate with batch mutations
-     * @throws Exception the exception
-     */
-    public IndexUpdate batchUpdateCollectionIndex(
-            IndexUpdate indexUpdate, EntityRef owner, String collectionName )
-            throws Exception {
-
-        logger.debug( "batchUpdateCollectionIndex" );
-
-        Entity indexedEntity = indexUpdate.getEntity();
-
-        String bucketId = indexBucketLocator
-                .getBucket( applicationId, IndexBucketLocator.IndexType.COLLECTION, indexedEntity.getUuid(),
-                        indexedEntity.getType(), indexUpdate.getEntryName() );
-
-        // the root name without the bucket
-        // entity_id,collection_name,prop_name,
-        Object index_name = null;
-        // entity_id,collection_name,prop_name, bucketId
-        Object index_key = null;
-
-        // entity_id,collection_name,collected_entity_id,prop_name
-
-        for ( IndexUpdate.IndexEntry entry : indexUpdate.getPrevEntries() ) {
-
-            if ( entry.getValue() != null ) {
-
-                index_name = key( owner.getUuid(), collectionName, entry.getPath() );
-
-                index_key = key( index_name, bucketId );
-
-                addDeleteToMutator( indexUpdate.getBatch(), ENTITY_INDEX, index_key,
-                        entry.getIndexComposite(), indexUpdate.getTimestamp() );
-
-                if ( "location.coordinates".equals( entry.getPath() ) ) {
-                    EntityLocationRef loc = new EntityLocationRef( indexUpdate.getEntity(),
-                            entry.getTimestampUuid(), entry.getValue().toString() );
-                    batchRemoveLocationFromCollectionIndex( indexUpdate.getBatch(),
-                            indexBucketLocator, applicationId, index_name, loc );
-                }
-            }
-            else {
-                logger.error( "Unexpected condition - deserialized property value is null" );
-            }
-        }
-
-        if ( ( indexUpdate.getNewEntries().size() > 0 )
-                && ( !indexUpdate.isMultiValue()
-                || ( indexUpdate.isMultiValue() && !indexUpdate.isRemoveListEntry() ) ) ) {
-
-            for ( IndexUpdate.IndexEntry indexEntry : indexUpdate.getNewEntries() ) {
-
-                // byte valueCode = indexEntry.getValueCode();
-
-                index_name = key( owner.getUuid(), collectionName, indexEntry.getPath() );
-
-                index_key = key( index_name, bucketId );
-
-                // int i = 0;
-
-                addInsertToMutator( indexUpdate.getBatch(), ENTITY_INDEX, index_key,
-                        indexEntry.getIndexComposite(), null, indexUpdate.getTimestamp() );
-
-                if ( "location.coordinates".equals( indexEntry.getPath() ) ) {
-                    EntityLocationRef loc = new EntityLocationRef(
-                            indexUpdate.getEntity(),
-                            indexEntry.getTimestampUuid(),
-                            indexEntry.getValue().toString() );
-                    batchStoreLocationInCollectionIndex(
-                            indexUpdate.getBatch(),
-                            indexBucketLocator,
-                            applicationId,
-                            index_name,
-                            indexedEntity.getUuid(),
-                            loc );
-                }
-
-                // i++;
-            }
-        }
-
-        for ( String index : indexUpdate.getIndexesSet() ) {
-            addInsertToMutator( indexUpdate.getBatch(), ENTITY_DICTIONARIES,
-                    key( owner.getUuid(), collectionName, Schema.DICTIONARY_INDEXES ), index, null,
-                    indexUpdate.getTimestamp() );
-        }
-
-        return indexUpdate;
-    }
-
-
 
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
index 90d9fdc..32b6eb2 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
@@ -24,21 +24,16 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.usergrid.corepersistence.CpEntityManagerFactory;
-import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 import org.apache.usergrid.persistence.EntityManagerFactory;
 import org.apache.usergrid.persistence.collection.MvccLogEntry;
 import org.apache.usergrid.persistence.collection.event.EntityVersionDeleted;
 import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-import org.apache.usergrid.persistence.graph.Edge;
 import org.apache.usergrid.persistence.graph.GraphManager;
 import org.apache.usergrid.persistence.graph.serialization.EdgesObservable;
 import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
 import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import org.apache.usergrid.persistence.index.IndexBatchBuffer;
-import org.apache.usergrid.persistence.index.IndexScope;
-import org.apache.usergrid.persistence.index.SearchEdge;
-import org.apache.usergrid.persistence.index.impl.IndexScopeImpl;
+import org.apache.usergrid.persistence.index.IndexEdge;
 import org.apache.usergrid.persistence.model.entity.Id;
 
 import com.google.inject.Inject;
@@ -100,12 +95,12 @@ public class EntityVersionDeletedHandler implements EntityVersionDeleted {
 
         //create an observable of all scopes to deIndex
         //remove all indexes pointing to this
-        final Observable<SearchEdge> targetScopes =  edgesObservable.edgesToTarget( gm, entityId ).map(
+        final Observable<IndexEdge> targetScopes =  edgesObservable.edgesToTarget( gm, entityId ).map(
             edge -> generateScopeFromSource( edge) );
 
 
         //Remove all double indexes
-        final Observable<IndexScope> sourceScopes = edgesObservable.edgesFromSource( gm, entityId ).map(
+        final Observable<IndexEdge> sourceScopes = edgesObservable.edgesFromSource( gm, entityId ).map(
                     edge -> generateScopeToTarget( edge ) );
 
 
@@ -134,11 +129,11 @@ public class EntityVersionDeletedHandler implements EntityVersionDeleted {
 
 
     private static final class IndexScopeVersion{
-        private final IndexScope scope;
+        private final IndexEdge scope;
         private final MvccLogEntry version;
 
 
-        private IndexScopeVersion( final IndexScope scope, final MvccLogEntry version ) {
+        private IndexScopeVersion( final IndexEdge scope, final MvccLogEntry version ) {
             this.scope = scope;
             this.version = version;
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ElasticSearchQueryExecutor.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ElasticSearchQueryExecutor.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ElasticSearchQueryExecutor.java
index f2b82ff..aa4f743 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ElasticSearchQueryExecutor.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ElasticSearchQueryExecutor.java
@@ -89,42 +89,38 @@ public class ElasticSearchQueryExecutor implements QueryExecutor {
         Results results = null;
         int queryCount = 0;
 
-        boolean satisfied = false;
 
+        CandidateResults crs = null;
 
-        while ( !satisfied && queryCount++ < maxQueries ) {
+        while ( queryCount++ < maxQueries ) {
 
-            CandidateResults crs = entityIndex.search( indexScope, types, query.getQl(), query.getLimit() );
+            crs = entityIndex.search( indexScope, types, query.getQl(), query.getLimit() );
 
             logger.debug( "Calling build results 1" );
             results = buildResults( indexScope, query, crs );
 
-            if ( crs.isEmpty() || !crs.hasCursor() ) { // no results, no cursor, can't get more
-                satisfied = true;
-            }
-
             /**
              * In an edge case where we delete stale entities, we could potentially get less results than expected.
              * This will only occur once during the repair phase.
              * We need to ensure that we short circuit before we overflow the requested limit during a repair.
              */
-            else if ( results.size() > 0 ) { // got what we need
-                satisfied = true;
+            if ( crs.isEmpty() || !crs.hasCursor() || results.size() > 0 ) { // no results, no cursor, can't get more
+                break;
             }
+
+
             //we didn't load anything, but there was a cursor, this means a read repair occured.  We have to short
             //circuit to avoid over returning the result set
-            else if ( crs.hasCursor() ) {
-                satisfied = false;
 
-                // need to query for more
-                // ask for just what we need to satisfy, don't want to exceed limit
-                query.setCursor( results.getCursor() );
-                query.setLimit( originalLimit - results.size() );
 
-                logger.warn( "Satisfy query limit {}, new limit {} query count {}", new Object[] {
-                    originalLimit, query.getLimit(), queryCount
-                } );
-            }
+            // need to query for more
+            // ask for just what we need to satisfy, don't want to exceed limit
+            query.setCursor( results.getCursor() );
+            query.setLimit( originalLimit - results.size() );
+
+            logger.warn( "Satisfy query limit {}, new limit {} query count {}", new Object[] {
+                originalLimit, query.getLimit(), queryCount
+            } );
         }
 
         //now set our cursor if we have one for the next iteration
@@ -138,6 +134,12 @@ public class ElasticSearchQueryExecutor implements QueryExecutor {
         }
 
 
+        //set our select subjects into our query if provided
+        if(crs != null){
+            query.setSelectSubjects( crs.getGetFieldMappings() );
+        }
+
+
         //set our current results and the flag
         this.currentResults = results;
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java b/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java
index 66152d4..163593e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java
@@ -19,62 +19,44 @@
 package org.apache.usergrid.persistence;
 
 
-import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.io.IOException;
 import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.ArrayList;
-import java.util.LinkedHashMap;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Set;
 import java.util.UUID;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.ClassicToken;
-import org.antlr.runtime.CommonTokenStream;
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.Token;
-import org.antlr.runtime.TokenRewriteStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang.StringUtils;
-import org.apache.usergrid.persistence.index.exceptions.IndexException;
+
+import org.apache.usergrid.persistence.index.SelectFieldMapping;
 import org.apache.usergrid.persistence.index.exceptions.QueryParseException;
-import org.apache.usergrid.persistence.index.impl.EsQueryVistor;
-import org.apache.usergrid.persistence.index.impl.IndexingUtils;
 import org.apache.usergrid.persistence.index.query.CounterResolution;
 import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.index.query.tree.AndOperand;
-import org.apache.usergrid.persistence.index.query.tree.ContainsOperand;
-import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterLexer;
-import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterParser;
-import org.apache.usergrid.persistence.index.query.tree.Equal;
-import org.apache.usergrid.persistence.index.query.tree.EqualityOperand;
-import org.apache.usergrid.persistence.index.query.tree.GreaterThan;
-import org.apache.usergrid.persistence.index.query.tree.GreaterThanEqual;
-import org.apache.usergrid.persistence.index.query.tree.LessThan;
-import org.apache.usergrid.persistence.index.query.tree.LessThanEqual;
 import org.apache.usergrid.persistence.index.query.tree.Operand;
-import org.apache.usergrid.persistence.index.query.tree.QueryVisitor;
 import org.apache.usergrid.persistence.index.utils.ClassUtils;
 import org.apache.usergrid.persistence.index.utils.ConversionUtils;
 import org.apache.usergrid.persistence.index.utils.ListUtils;
 import org.apache.usergrid.persistence.index.utils.MapUtils;
-import org.elasticsearch.index.query.FilterBuilder;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.databind.ObjectMapper;
 
 
 
 public class Query {
     private static final Logger logger = LoggerFactory.getLogger( Query.class );
 
+
+
+
     public enum Level {
         IDS, REFS, CORE_PROPERTIES, ALL_PROPERTIES, LINKED_PROPERTIES
     }
@@ -105,6 +87,7 @@ public class Query {
     private List<CounterFilterPredicate> counterFilters;
     private String collection;
     private String ql;
+    private Collection<SelectFieldMapping> selectFields;
 
     private static ObjectMapper mapper = new ObjectMapper();
 
@@ -339,6 +322,31 @@ public class Query {
     }
 
 
+    /**
+     * Return true if the query generated select subjects
+     * @return
+     */
+    public boolean hasSelectSubjects() {
+        return this.selectFields != null || this.selectFields.size() > 0;
+    }
+
+
+    /**
+     * Set the select subjects from our query results
+     */
+    public void setSelectSubjects( final Collection<SelectFieldMapping> selectFields ) {
+        this.selectFields = selectFields;
+    }
+
+
+    /**
+     * Get the select assignments from our resetus if they were set
+     */
+    public Collection<SelectFieldMapping> getSelectAssignments() {
+        return this.selectFields;
+    }
+
+
     public boolean containsNameOrEmailIdentifiersOnly() {
         if ( hasQueryPredicates() ) {
             return false;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/main/java/org/apache/usergrid/persistence/QueryUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/QueryUtils.java b/stack/core/src/main/java/org/apache/usergrid/persistence/QueryUtils.java
index 4f8ad18..b2397c8 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/QueryUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/QueryUtils.java
@@ -18,16 +18,17 @@ package org.apache.usergrid.persistence;
 
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
-import org.apache.usergrid.persistence.Query;
-import static org.apache.usergrid.utils.ClassUtils.cast;
-import org.apache.usergrid.utils.JsonUtils;
 
+import org.apache.usergrid.persistence.index.SelectFieldMapping;
+import org.apache.usergrid.utils.JsonUtils;
 import org.apache.usergrid.utils.ListUtils;
 
+import static org.apache.usergrid.utils.ClassUtils.cast;
+
 
 /**
  * Utilities to deal with query extraction and generation
@@ -54,6 +55,13 @@ public class QueryUtils {
         return null;
     }
 
+
+    /**
+     * When a query has select fields, parse the results into a result set by the field mappings
+     * @param q
+     * @param rs
+     * @return
+     */
     public static List<Object> getSelectionResults( Query q, Results rs ) {
 
         List<Entity> entities = rs.getEntities();
@@ -68,33 +76,14 @@ public class QueryUtils {
         List<Object> results = new ArrayList<Object>();
 
         for ( Entity entity : entities ) {
-            if ( q.isMergeSelectResults() ) {
-                boolean include = false;
-                Map<String, Object> result = new LinkedHashMap<String, Object>();
-                Map<String, String> selects = q.getSelectAssignments();
-                for ( Map.Entry<String, String> select : selects.entrySet() ) {
-                    Object obj = JsonUtils.select( entity, select.getValue(), false );
-                    if ( obj != null ) {
-                        include = true;
-                    }
-                    result.put( select.getKey(), obj );
-                }
-                if ( include ) {
-                    results.add( result );
-                }
-            }
-            else {
-                boolean include = false;
-                List<Object> result = new ArrayList<Object>();
-                Set<String> selects = q.getSelectSubjects();
-                for ( String select : selects ) {
-                    Object obj = JsonUtils.select( entity, select );
-                    if ( obj != null ) {
-                        include = true;
-                    }
-                    result.add( obj );
-                }
-                if ( include ) {
+
+
+            Collection<SelectFieldMapping> selects = q.getSelectAssignments();
+            for ( SelectFieldMapping select : selects ) {
+                Object obj = JsonUtils.select( entity, select.getSourceFieldName(), false );
+                if ( obj != null ) {
+                    Map<String, Object> result = new LinkedHashMap<String, Object>();
+                    result.put( select.getTargetFieldName(), obj );
                     results.add( result );
                 }
             }
@@ -106,14 +95,4 @@ public class QueryUtils {
 
         return results;
     }
-
-
-    public static Object getSelectionResult( Query q, Results rs ) {
-        List<Object> r = QueryUtils.getSelectionResults( q, rs );
-        if ( ( r != null ) && ( r.size() > 0 ) ) {
-            return r.get( 0 );
-        }
-        return null;
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java b/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
index 52a4806..218ea3a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
@@ -116,6 +116,5 @@ public interface RelationManager {
 
     public Set<String> getConnectionIndexes( String connectionType ) throws Exception;
 
-    public void batchUpdateSetIndexes( Mutator<ByteBuffer> batch, String setName, Object elementValue,
-                                       boolean removeFromSet, UUID timestampUuid ) throws Exception;
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/Application.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/Application.java b/stack/core/src/test/java/org/apache/usergrid/Application.java
index faa9b4f..56028bb 100644
--- a/stack/core/src/test/java/org/apache/usergrid/Application.java
+++ b/stack/core/src/test/java/org/apache/usergrid/Application.java
@@ -26,7 +26,7 @@ import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.EntityRef;
 import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
index c59ff72..d3861a6 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -36,7 +36,7 @@ import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.EntityRef;
 import org.apache.usergrid.persistence.Results;
 import org.apache.usergrid.persistence.SimpleEntityRef;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 
 import static junit.framework.Assert.assertNotNull;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java
index abc5a13..6bba8b3 100644
--- a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java
@@ -24,7 +24,7 @@ import org.junit.Test;
 
 import org.apache.usergrid.persistence.Results;
 import org.apache.usergrid.persistence.entities.JobData;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.utils.UUIDUtils;
 
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
index f743f0b..ce12419 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
@@ -46,12 +46,11 @@ import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
 import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
+import org.apache.usergrid.persistence.index.CandidateResults;
 import org.apache.usergrid.persistence.index.EntityIndexFactory;
-import org.apache.usergrid.persistence.index.IndexScope;
+import org.apache.usergrid.persistence.index.SearchEdge;
 import org.apache.usergrid.persistence.index.SearchTypes;
-import org.apache.usergrid.persistence.index.impl.IndexScopeImpl;
-import org.apache.usergrid.persistence.index.query.CandidateResults;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 
@@ -61,7 +60,6 @@ import com.google.inject.Injector;
 import net.jcip.annotations.NotThreadSafe;
 
 import static org.apache.usergrid.corepersistence.CoreModule.EVENTS_DISABLED;
-import static org.apache.usergrid.corepersistence.util.CpNamingUtils.generateScopeFromCollection;
 import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
 import static org.apache.usergrid.persistence.core.util.IdGenerator.createId;
 import static org.junit.Assert.assertEquals;
@@ -494,13 +492,10 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
         ApplicationEntityIndex ei = eif.createApplicationEntityIndex(as);
 
         final Id rootId = createId(em.getApplicationId(), TYPE_APPLICATION);
-        IndexScope is = generateScopeFromCollection(rootId, collName );
-        Query rcq = Query.fromQL( query );
+        SearchEdge is = CpNamingUtils.createCollectionSearchEdge( rootId, collName );
 
-        // TODO: why does this have no effect; max we ever get is 1000 entities
-        rcq.setLimit( 10000 ); // no paging
 
-        return ei.search( is, SearchTypes.fromTypes( type ), rcq );
+        return ei.search( is, SearchTypes.fromTypes( type ), query, 10000 );
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
index 129a701..3f05d05 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
@@ -36,8 +36,8 @@ import org.apache.usergrid.CoreApplication;
 import org.apache.usergrid.persistence.entities.User;
 import org.apache.usergrid.persistence.exceptions.DuplicateUniquePropertyExistsException;
 import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Query.Level;
 import org.apache.usergrid.utils.JsonUtils;
 import org.apache.usergrid.utils.UUIDUtils;
 
@@ -146,13 +146,12 @@ public class CollectionIT extends AbstractCoreIT {
         assertEquals( 3, r.size() ); // success
 
         // query verb
-        query = new Query().addEqualityFilter( "verb", "tweet2" );
+        query = Query.fromQL( "verb = 'tweet2'" );
         r = app.searchCollection( user, "activities", query );
         assertEquals( 2, r.size() );
 
         // query verb, sort created
-        query = new Query().addEqualityFilter( "verb", "tweet2" );
-        query.addSort( "created" );
+        query = Query.fromQL( "verb = 'tweet2' order by created" );
         r = app.searchCollection( user, "activities", query );
         assertEquals( 2, r.size() );
         List<Entity> entities = r.getEntities();
@@ -160,8 +159,7 @@ public class CollectionIT extends AbstractCoreIT {
         assertEquals( entities.get( 1 ).getUuid(), activity3.getUuid() );
 
         // query verb, sort ordinal
-        query = new Query().addEqualityFilter( "verb", "tweet2" );
-        query.addSort( "ordinal" );
+        query = Query.fromQL( "verb = 'tweet2' order by ordinal" );
         r = app.searchCollection( user, "activities", query );
         assertEquals( 2, r.size() );
         entities = r.getEntities();
@@ -172,8 +170,7 @@ public class CollectionIT extends AbstractCoreIT {
         // it works in the exact same test in the QueryIndex module/
 
 //        // empty query, sort content
-        query = new Query();
-        query.addSort( "content" );
+        query = Query.fromQL( "order by content" );
         r = app.searchCollection( user, "activities", query );
         assertEquals( 3, r.size() );
         entities = r.getEntities();
@@ -183,14 +180,12 @@ public class CollectionIT extends AbstractCoreIT {
         assertEquals( entities.get( 2 ).getUuid(), activity3.getUuid() );
 
         // empty query, sort verb
-        query = new Query();
-        query.addSort( "verb" );
+        query =  Query.fromQL( "order by verb" );
         r = app.searchCollection( user, "activities", query );
         assertEquals( 3, r.size() );
 
         // empty query, sort ordinal
-        query = new Query();
-        query.addSort( "ordinal" );
+        query =  Query.fromQL( "order by ordinal" );
         r = app.searchCollection( user, "activities", query );
         assertEquals( 3, r.size() );
         entities = r.getEntities();
@@ -199,13 +194,12 @@ public class CollectionIT extends AbstractCoreIT {
         assertEquals( entities.get( 2 ).getUuid(), activity.getUuid() );
 
         // query ordinal
-        query = new Query().addEqualityFilter( "ordinal", 2 );
+        query =  Query.fromQL( "ordinal = 2" );
         r = app.searchCollection( user, "activities", query );
         assertEquals( 1, r.size() );
 
         // query ordinal and sort ordinal
-        query = new Query().addEqualityFilter( "ordinal", 2 );
-        query.addSort( "ordinal" );
+        query =  Query.fromQL( "ordinal = 2 order by ordinal");
         r = app.searchCollection( user, "activities", query );
         assertEquals( 1, r.size() );
     }
@@ -231,8 +225,7 @@ public class CollectionIT extends AbstractCoreIT {
         app.refreshIndex();
 
         // EntityRef
-        Query query = new Query();
-        query.addEqualityFilter( "firstname", firstName );
+        Query query = Query.fromQL( "firstname = '" + firstName + "'" );
 
         Results r = em.searchCollection( em.getApplicationRef(), "users", query );
 
@@ -252,15 +245,14 @@ public class CollectionIT extends AbstractCoreIT {
         app.refreshIndex();
 
         // search with the old username, should be no results
-        query.addEqualityFilter( "firstname", firstName );
+        query = Query.fromQL( "firstname = '" + firstName + "'" );
         r = em.searchCollection( em.getApplicationRef(), "users", query );
 
         assertEquals( 0, r.size() );
 
         // search with the new username, should be results.
 
-        query = new Query();
-        query.addEqualityFilter( "firstname", newFirstName );
+        query = Query.fromQL( "firstname = '" + newFirstName + "'" );
 
         r = em.searchCollection( em.getApplicationRef(), "users", query );
 
@@ -292,8 +284,7 @@ public class CollectionIT extends AbstractCoreIT {
         app.refreshIndex();
 
         // EntityRef
-        Query query = new Query();
-        query.addEqualityFilter( "middlename", middleName );
+        final Query query = Query.fromQL( "middlename = '" + middleName + "'" );
 
         Results r = em.searchCollection( em.getApplicationRef(), "users", query );
 
@@ -325,8 +316,7 @@ public class CollectionIT extends AbstractCoreIT {
         app.refreshIndex();
 
         // EntityRef
-        Query query = new Query();
-        query.addEqualityFilter( "lastname", lastName );
+        final Query query = Query.fromQL( "lastname = '" + lastName + "'" );
 
         Results r = em.searchCollection( em.getApplicationRef(), "users", query );
 
@@ -373,9 +363,11 @@ public class CollectionIT extends AbstractCoreIT {
 
         app.refreshIndex();
 
+        final Query query = Query.fromQL( "nickname = 'ed'" );
+
         Results r = em.searchCollection( group, "users",
-            new Query().addEqualityFilter( "nickname", "ed" )
-                .withResultsLevel(Level.LINKED_PROPERTIES ) );
+            query
+                .withResultsLevel( Level.LINKED_PROPERTIES ) );
 
         LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
         assertEquals( 1, r.size() );
@@ -404,8 +396,7 @@ public class CollectionIT extends AbstractCoreIT {
         app.refreshIndex();
 
         // EntityRef
-        Query query = new Query();
-        query.addEqualityFilter( "name", groupName );
+        final Query query = Query.fromQL( "name = '" + groupName + "'" );
 
         Results r = em.searchCollection( em.getApplicationRef(), "groups", query );
 
@@ -437,8 +428,8 @@ public class CollectionIT extends AbstractCoreIT {
         app.refreshIndex();
 
         // EntityRef
-        Query query = new Query();
-        query.addEqualityFilter( "title", titleName );
+
+        final Query query = Query.fromQL( "title = '" + titleName + "'" );
 
         Results r = em.searchCollection( em.getApplicationRef(), "groups", query );
 
@@ -494,7 +485,9 @@ public class CollectionIT extends AbstractCoreIT {
 
         app.refreshIndex();
 
-        Results r = em.searchCollection( user, "activities", Query.searchForProperty( "verb", "post" ) );
+        final Query query = Query.fromQL( "verb = 'post'" );
+
+        Results r = em.searchCollection( user, "activities", query);
         LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
         assertEquals( 2, r.size() );
     }
@@ -1019,10 +1012,7 @@ public class CollectionIT extends AbstractCoreIT {
         int pageSize = 10;
 
         app.refreshIndex();
-
-        Query query = new Query();
-        query.setLimit( pageSize );
-        query.addFilter( "index < " + size * 2 );
+        final Query query = Query.fromQL( "index < " + size * 2 );
 
         Results r = null;
 
@@ -1073,9 +1063,8 @@ public class CollectionIT extends AbstractCoreIT {
 
         app.refreshIndex();
 
-        Query query = Query.fromQL("select * where index >= " + size / 2);
+        Query query = Query.fromQL("select * where index >= " + size / 2 + " + sort by index asc");
         query.setLimit( pageSize );
-        query.addSort(new Query.SortPredicate("index", Query.SortDirection.ASCENDING));
 
         Results r = null;
 
@@ -1125,9 +1114,8 @@ public class CollectionIT extends AbstractCoreIT {
 
         int pageSize = 10;
 
-        Query query = Query.fromQL("select * where index >= 10 and index <= 29");
+        Query query = Query.fromQL("select * where index >= 10 and index <= 29 sort by index asc");
         query.setLimit( pageSize );
-        query.addSort(new Query.SortPredicate("index", Query.SortDirection.ASCENDING));
 
         Results r = null;
 
@@ -1177,9 +1165,8 @@ public class CollectionIT extends AbstractCoreIT {
 
         int pageSize = 10;
 
-        Query query = Query.fromQL("select * where index >= 10 and index <= 29");
+        Query query = Query.fromQL("select * where index >= 10 and index <= 29 sort by index asc");
         query.setLimit( pageSize );
-        query.addSort(new Query.SortPredicate("index", Query.SortDirection.ASCENDING));
 
         Results r = em.searchCollection( em.getApplicationRef(), "pages", query );
 
@@ -1227,18 +1214,16 @@ public class CollectionIT extends AbstractCoreIT {
 
         app.refreshIndex();
 
-        Query query = new Query();
-        query.addEqualityFilter( "rootprop1", "simpleprop" );
+        Query query = Query.fromQL( "rootprop1 = 'simpleprop'" );
         Entity entity;
         Results results;
-        results = em.searchCollection(em.getApplicationRef(), "tests", query);
-        entity = results.getEntitiesMap().get(saved.getUuid());
+        results = em.searchCollection( em.getApplicationRef(), "tests", query );
+        entity = results.getEntitiesMap().get( saved.getUuid() );
 
         assertNotNull( entity );
 
         // query on the nested int value
-        query = new Query();
-        query.addEqualityFilter( "subentity.intprop", 10 );
+        query = Query.fromQL( "subentity.intprop = 10" );
 
         results = em.searchCollection( em.getApplicationRef(), "tests", query );
 
@@ -1247,9 +1232,7 @@ public class CollectionIT extends AbstractCoreIT {
         assertNotNull( entity );
 
         // query on the nexted tokenized value
-        query = new Query();
-        query.addContainsFilter( "subentity.substring", "tokenized" );
-        query.addContainsFilter( "subentity.substring", "indexed" );
+        query = Query.fromQL(  "subentity.substring contains 'tokenized' and subentity.substring contains 'indexed'" );
 
         results = em.searchCollection( em.getApplicationRef(), "tests", query );
 
@@ -1278,8 +1261,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         app.refreshIndex();
 
-        Query query = new Query();
-        query.addEqualityFilter( "intprop", 10 );
+        Query query = Query.fromQL( "intprop = 10" );
 
         Results results = em.searchCollection( em.getApplicationRef(), "tests", query );
 
@@ -1288,8 +1270,7 @@ public class CollectionIT extends AbstractCoreIT {
         assertNotNull( entity );
 
         // query on the nested int value
-        query = new Query();
-        query.addEqualityFilter( "array", "val1" );
+        query = Query.fromQL( "array = 'val1'" );
 
         results = em.searchCollection( em.getApplicationRef(), "tests", query );
 
@@ -1298,8 +1279,7 @@ public class CollectionIT extends AbstractCoreIT {
         assertNotNull( entity );
 
         // query on the nexted tokenized value
-        query = new Query();
-        query.addEqualityFilter( "array", "val2" );
+        query = Query.fromQL( "array = 'val2'" );
 
         results = em.searchCollection( em.getApplicationRef(), "tests", query );
 
@@ -1307,8 +1287,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         assertNotNull( entity );
 
-        query = new Query();
-        query.addEqualityFilter( "array", "val3" );
+        query = Query.fromQL( "array = 'val3'" );
 
         results = em.searchCollection( em.getApplicationRef(), "tests", query );
 
@@ -1316,8 +1295,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         assertNull( entity );
 
-        query = new Query();
-        query.addContainsFilter( "array", "spaces" );
+        query = Query.fromQL( "array contains 'spaces'" );
         results = em.searchCollection( em.getApplicationRef(), "tests", query );
 
         entity = results.getEntitiesMap().get( saved.getUuid() );
@@ -1342,8 +1320,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         app.refreshIndex();
 
-        Query query = new Query();
-        query.addEqualityFilter( "myString", "My simple string" );
+        Query query = Query.fromQL("myString = 'My simple string'" );
 
         Results results = em.searchCollection( em.getApplicationRef(), "tests", query );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
index a5e1493..5bc448f 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
@@ -37,7 +37,7 @@ import org.apache.usergrid.persistence.entities.Event;
 import org.apache.usergrid.persistence.entities.Group;
 import org.apache.usergrid.persistence.entities.User;
 import org.apache.usergrid.persistence.index.query.CounterResolution;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import org.apache.usergrid.utils.ImmediateCounterRule;
 import org.apache.usergrid.utils.JsonUtils;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
index 175cc74..abb9417 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
@@ -31,7 +31,7 @@ import org.apache.commons.lang3.RandomStringUtils;
 
 import org.apache.usergrid.AbstractCoreIT;
 import org.apache.usergrid.persistence.hector.CountingMutator;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import org.apache.usergrid.utils.UUIDUtils;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
index 2e7de4f..6b508b4 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.usergrid.AbstractCoreIT;
 import org.apache.usergrid.persistence.entities.User;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
index cd255c6..ec79261 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
@@ -37,8 +37,8 @@ import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.usergrid.AbstractCoreIT;
 import org.apache.usergrid.persistence.entities.Group;
 import org.apache.usergrid.persistence.entities.User;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Query.Level;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import org.apache.usergrid.utils.UUIDUtils;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
index c50ccaf..ebf0a6a 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
@@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.usergrid.AbstractCoreIT;
 import org.apache.usergrid.persistence.geo.model.Point;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.model.field.value.Location;
 import org.apache.usergrid.utils.MapUtils;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
index 3dfab3f..1248276 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
@@ -30,7 +30,7 @@ import org.apache.commons.lang3.RandomStringUtils;
 
 import org.apache.usergrid.AbstractCoreIT;
 import org.apache.usergrid.persistence.geo.model.Point;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
index a60a6b5..0ba8926 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
@@ -32,7 +32,7 @@ import org.apache.usergrid.persistence.cassandra.CassandraService;
 import org.apache.usergrid.persistence.cassandra.IndexUpdate;
 import org.apache.usergrid.persistence.cassandra.IndexUpdate.IndexEntry;
 import org.apache.usergrid.persistence.cassandra.RelationManagerImpl;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.utils.JsonUtils;
 import org.apache.usergrid.utils.UUIDUtils;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
index 6bddf76..d0b1b28 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
@@ -28,8 +28,8 @@ import java.util.UUID;
 import org.junit.Test;
 
 import org.apache.usergrid.AbstractCoreIT;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Query.Level;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index 9336df8..b0fc245 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -40,7 +40,7 @@ import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
 import org.apache.usergrid.persistence.index.EntityIndex;
 import org.apache.usergrid.persistence.index.EntityIndexFactory;
 import org.apache.usergrid.persistence.index.impl.EsEntityIndexImpl;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
index 6f76a79..bfdc3cf 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
@@ -31,7 +31,7 @@ import org.apache.commons.lang3.RandomStringUtils;
 
 import org.apache.usergrid.AbstractCoreIT;
 import org.apache.usergrid.persistence.entities.Role;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java
index 1b4bb6f..5d16e11 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java
@@ -26,9 +26,9 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.usergrid.persistence.index.exceptions.QueryParseException;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.query.Query.SortDirection;
-import org.apache.usergrid.persistence.index.query.Query.SortPredicate;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Query.SortDirection;
+import org.apache.usergrid.persistence.Query.SortPredicate;
 import org.apache.usergrid.persistence.index.query.tree.AndOperand;
 import org.apache.usergrid.persistence.index.query.tree.ContainsOperand;
 import org.apache.usergrid.persistence.index.query.tree.Equal;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java
index 6d1ab8a..b04c419 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java
@@ -29,7 +29,7 @@ import org.junit.Test;
 import org.apache.usergrid.mq.QueryFilterLexer;
 import org.apache.usergrid.mq.QueryFilterParser;
 import org.apache.usergrid.persistence.exceptions.PersistenceException;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterLexer;
 import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterParser;
 import org.apache.usergrid.persistence.query.ir.AndNode;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
index 8965013..8cc3b73 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
@@ -25,7 +25,7 @@ import java.util.Map;
 import org.apache.usergrid.CoreApplication;
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
index 5f9874b..e99ae9c 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
@@ -26,7 +26,7 @@ import java.util.Map;
 import org.apache.usergrid.CoreApplication;
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java
index 195ccdb..3b12353 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java
@@ -33,7 +33,7 @@ import org.apache.usergrid.CoreApplication;
 import org.apache.usergrid.CoreITSetup;
 import org.apache.usergrid.CoreITSetupImpl;
 import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 
 import static org.junit.Assert.assertEquals;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
index b78bc46..e8ee0b6 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
@@ -34,7 +34,7 @@ import org.apache.usergrid.CoreITSetup;
 import org.apache.usergrid.CoreITSetupImpl;
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java
index 1032bd0..cb1f020 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java
@@ -24,7 +24,7 @@ import java.util.Map;
 
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
index c2b8b87..8bd965c 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
@@ -37,7 +37,7 @@ import org.apache.usergrid.CoreITSetup;
 import org.apache.usergrid.CoreITSetupImpl;
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/core/src/test/java/org/apache/usergrid/persistence/query/NotSubPropertyIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/NotSubPropertyIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/NotSubPropertyIT.java
index d0b292d..ff66f8e 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/NotSubPropertyIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/NotSubPropertyIT.java
@@ -33,7 +33,7 @@ import org.apache.usergrid.CoreApplication;
 import org.apache.usergrid.CoreITSetup;
 import org.apache.usergrid.CoreITSetupImpl;
 import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 
 import static org.junit.Assert.assertEquals;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
index 940effc..7748adb 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
@@ -89,6 +89,11 @@ public class CandidateResults implements Iterable<CandidateResult> {
     }
 
 
+    public Collection<SelectFieldMapping> getGetFieldMappings() {
+        return getFieldMappings;
+    }
+
+
     /**
      * Get the candidates
      * @return

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
index eaa2531..d86e83f 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
@@ -17,15 +17,6 @@
 package org.apache.usergrid.rest.applications;
 
 
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.multipart.BodyPart;
-import com.sun.jersey.multipart.BodyPartEntity;
-import com.sun.jersey.multipart.FormDataBodyPart;
-import com.sun.jersey.multipart.FormDataMultiPart;
-import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Date;
@@ -33,6 +24,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.DefaultValue;
@@ -46,16 +38,23 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
 import org.apache.commons.lang.StringUtils;
+
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.QueryUtils;
-import org.apache.usergrid.persistence.index.query.Query;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.RootResource;
@@ -72,11 +71,15 @@ import org.apache.usergrid.services.assets.data.AssetUtils;
 import org.apache.usergrid.services.assets.data.BinaryStore;
 import org.apache.usergrid.utils.InflectionUtils;
 import org.apache.usergrid.utils.JsonUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.sun.jersey.api.json.JSONWithPadding;
+import com.sun.jersey.multipart.BodyPart;
+import com.sun.jersey.multipart.BodyPartEntity;
+import com.sun.jersey.multipart.FormDataBodyPart;
+import com.sun.jersey.multipart.FormDataMultiPart;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
 
 
 @Component

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/services/src/main/java/org/apache/usergrid/services/ServiceParameter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/ServiceParameter.java b/stack/services/src/main/java/org/apache/usergrid/services/ServiceParameter.java
index fc195ac..6e8a072 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/ServiceParameter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/ServiceParameter.java
@@ -25,8 +25,9 @@ import java.util.UUID;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.index.query.Query;
 
 import static org.apache.commons.lang.StringUtils.isNotBlank;
 import static org.apache.usergrid.utils.ListUtils.dequeue;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/services/src/main/java/org/apache/usergrid/services/ServiceRequest.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/ServiceRequest.java b/stack/services/src/main/java/org/apache/usergrid/services/ServiceRequest.java
index 69cff6c..90c3b7e 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/ServiceRequest.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/ServiceRequest.java
@@ -26,7 +26,7 @@ import java.util.List;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.services.ServiceParameter.QueryParameter;
 import org.apache.usergrid.services.ServiceResults.Type;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/035cb783/stack/services/src/main/java/org/apache/usergrid/services/ServiceResults.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/ServiceResults.java b/stack/services/src/main/java/org/apache/usergrid/services/ServiceResults.java
index 7a516ba..3db0064 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/ServiceResults.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/ServiceResults.java
@@ -23,11 +23,11 @@ import java.util.UUID;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 import org.apache.usergrid.persistence.AggregateCounterSet;
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.QueryUtils;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.Results;
 
 
@@ -127,45 +127,11 @@ public class ServiceResults extends Results {
     }
 
 
-    public ServiceResults getPreviousResults() {
-        return previousResults;
-    }
-
-
     public Map<String, Object> getServiceMetadata() {
         return serviceMetadata;
     }
 
 
-    public boolean hasSelection() {
-        if ( request == null ) {
-            return false;
-        }
-        Query q = getQuery();
-        if ( q != null ) {
-            return q.hasSelectSubjects();
-        }
-        return false;
-    }
-
-
-    public List<Object> getSelectionResults() {
-        Query q = getQuery();
-        if ( q == null ) {
-            return null;
-        }
-        return QueryUtils.getSelectionResults( q, this );
-    }
-
-
-    public Object getSelectionResult() {
-        Query q = getQuery();
-        if ( q == null ) {
-            return null;
-        }
-        return QueryUtils.getSelectionResult( q, this );
-    }
-
 
     public String getPath() {
         return path;


Mime
View raw message