geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ash...@apache.org
Subject [13/50] [abbrv] incubator-geode git commit: Refactoring LuceneFunction, LuceneQueryProvider, and LuceneQueryFactory
Date Wed, 11 Nov 2015 21:23:45 GMT
Refactoring LuceneFunction, LuceneQueryProvider, and LuceneQueryFactory

LuceneFunction had a static RepositoryManager, I changed the code to get
look up the RepositoryManager from the LuceneService.

As part of that work, I noticed StringQueryProvider really needed access
to the index to lookup the field names, analyzer, etc. So I changed the
getQuery method to take an index, and removed the unneeded string
parameters.

Finally, I removed some of the mocking from
LuceneFunctionReadPathDUnitTest, which exposed some other issues:

* I switched RepositoryManager.getRepositories back to using a
RegionFunctionContext, because apparently context.getDataSet is *not*
the local data set.

* I canonicalized the regionPaths in LuceneService


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

Branch: refs/heads/develop
Commit: 8fb4ad7a23db081377e1a93b7da839809095eb70
Parents: 58f13e2
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Wed Sep 23 13:37:05 2015 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Wed Sep 23 15:42:38 2015 -0700

----------------------------------------------------------------------
 .../internal/cache/GemFireCacheImpl.java        |  2 +-
 .../gemfire/internal/cache/InternalCache.java   |  3 +-
 .../internal/cache/xmlcache/CacheCreation.java  |  2 +-
 .../cache/lucene/LuceneQueryFactory.java        | 16 ----
 .../cache/lucene/LuceneQueryProvider.java       |  3 +-
 .../cache/lucene/LuceneServiceProvider.java     |  3 +-
 .../lucene/internal/InternalLuceneIndex.java    | 10 +++
 .../lucene/internal/InternalLuceneService.java  |  9 ++
 .../cache/lucene/internal/LuceneIndexImpl.java  |  3 +-
 .../lucene/internal/LuceneQueryFactoryImpl.java | 31 ++-----
 .../cache/lucene/internal/LuceneQueryImpl.java  | 11 +--
 .../lucene/internal/LuceneServiceImpl.java      | 20 +++--
 .../internal/PartitionedRepositoryManager.java  | 13 +--
 .../lucene/internal/StringQueryProvider.java    | 45 ++--------
 .../internal/distributed/LuceneFunction.java    | 26 +++---
 .../distributed/LuceneFunctionContext.java      | 26 ++++--
 .../internal/repository/RepositoryManager.java  |  2 +-
 .../internal/LuceneServiceImplJUnitTest.java    | 12 +--
 .../PartitionedRepositoryManagerJUnitTest.java  | 13 ++-
 .../internal/StringQueryProviderJUnitTest.java  | 22 ++---
 .../LuceneFunctionContextJUnitTest.java         |  8 +-
 .../distributed/LuceneFunctionJUnitTest.java    | 95 +++++++++++++-------
 .../LuceneFunctionReadPathDUnitTest.java        | 80 ++++++++---------
 .../TopEntriesFunctionCollectorJUnitTest.java   |  6 +-
 .../IndexRepositoryImplJUnitTest.java           |  6 ++
 25 files changed, 239 insertions(+), 228 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
index ed83a76..6fe639b 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
@@ -238,7 +238,7 @@ import com.sun.jna.Platform;
  * @author Darrel Schneider
  */
 @SuppressWarnings("deprecation")
-public class GemFireCacheImpl implements InternalCache, ClientCache, HasCachePerfStats, DistributionAdvisee, Extensible<Cache> {
+public class GemFireCacheImpl implements InternalCache, ClientCache, HasCachePerfStats, DistributionAdvisee {
   private static final Logger logger = LogService.getLogger();
   
   // moved *SERIAL_NUMBER stuff to DistributionAdvisor

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/InternalCache.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/InternalCache.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/InternalCache.java
index 7c1fa8e..cf1a4dc 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/InternalCache.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/InternalCache.java
@@ -14,6 +14,7 @@ import com.gemstone.gemfire.cache.hdfs.internal.HDFSStoreImpl;
 import com.gemstone.gemfire.cache.hdfs.internal.hoplog.HDFSStoreDirector;
 import com.gemstone.gemfire.cache.query.internal.cq.CqService;
 import com.gemstone.gemfire.distributed.DistributedMember;
+import com.gemstone.gemfire.internal.cache.extension.Extensible;
 
 /**
  * The InternalCache interface is contract for implementing classes for defining internal cache operations that should
@@ -23,7 +24,7 @@ import com.gemstone.gemfire.distributed.DistributedMember;
  * @see com.gemstone.gemfire.cache.Cache
  * @since 7.0
  */
-public interface InternalCache extends Cache {
+public interface InternalCache extends Cache, Extensible<Cache> {
 
   public DistributedMember getMyId();
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java
index 04630ba..2e2ec2b 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java
@@ -126,7 +126,7 @@ import com.gemstone.gemfire.pdx.internal.TypeRegistry;
  *
  * @since 3.0
  */
-public class CacheCreation implements InternalCache, Extensible<Cache> {
+public class CacheCreation implements InternalCache {
 
   /** The amount of time to wait for a distributed lock */
   private int lockTimeout = GemFireCacheImpl.DEFAULT_LOCK_TIMEOUT;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryFactory.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryFactory.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryFactory.java
index 1775b40..55f1b3a 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryFactory.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryFactory.java
@@ -1,6 +1,5 @@
 package com.gemstone.gemfire.cache.lucene;
 
-import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.queryparser.classic.ParseException;
 
 /**
@@ -50,21 +49,6 @@ public interface LuceneQueryFactory {
   LuceneQueryFactory setProjectionFields(String... fieldNames);
   
   /**
-   * Create wrapper object for lucene's QueryParser object.
-   * The queryString is using lucene QueryParser's syntax. QueryParser is for easy-to-use 
-   * with human understandable syntax. 
-   *  
-   * @param regionName region name
-   * @param indexName index name
-   * @param queryString query string in lucene QueryParser's syntax
-   * @param analyzer lucene Analyzer to parse the queryString
-   * @return LuceneQuery object
-   * @throws ParseException
-   */
-  public LuceneQuery create(String indexName, String regionName, String queryString, 
-      Analyzer analyzer) throws ParseException;
-  
-  /**
    * Create wrapper object for lucene's QueryParser object using default standard analyzer.
    * The queryString is using lucene QueryParser's syntax. QueryParser is for easy-to-use 
    * with human understandable syntax. 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryProvider.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryProvider.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryProvider.java
index 767bfa8..a113fab 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryProvider.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryProvider.java
@@ -17,7 +17,8 @@ import com.gemstone.gemfire.cache.query.QueryException;
 public interface LuceneQueryProvider extends Serializable {
   /**
    * @return A Lucene Query object which could be used for executing Lucene Search on indexed data
+   * @param The local lucene index the query is being constructed against.
    * @throws QueryException if the provider fails to construct the query object
    */
-  public Query getQuery() throws QueryException;
+  public Query getQuery(LuceneIndex index) throws QueryException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneServiceProvider.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneServiceProvider.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneServiceProvider.java
index b276b48..7d90b7d 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneServiceProvider.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneServiceProvider.java
@@ -1,6 +1,7 @@
 package com.gemstone.gemfire.cache.lucene;
 
 import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.lucene.internal.InternalLuceneService;
 import com.gemstone.gemfire.cache.lucene.internal.LuceneServiceImpl;
 import com.gemstone.gemfire.internal.cache.extension.Extensible;
 
@@ -17,7 +18,7 @@ public class LuceneServiceProvider {
   public static LuceneService get(Cache cache) {
     synchronized(LuceneService.class) {
       Extensible<Cache> extensible = (Extensible<Cache>) cache;
-      LuceneServiceImpl service = (LuceneServiceImpl) extensible.getExtensionPoint().getExtension(LuceneService.class);
+      InternalLuceneService service = (InternalLuceneService) extensible.getExtensionPoint().getExtension(LuceneService.class);
       if(service == null) {
         service = new LuceneServiceImpl(cache);
         extensible.getExtensionPoint().addExtension(LuceneService.class, service);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneIndex.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneIndex.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneIndex.java
new file mode 100644
index 0000000..ab2c924
--- /dev/null
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneIndex.java
@@ -0,0 +1,10 @@
+package com.gemstone.gemfire.cache.lucene.internal;
+
+import com.gemstone.gemfire.cache.lucene.LuceneIndex;
+import com.gemstone.gemfire.cache.lucene.internal.repository.RepositoryManager;
+
+public interface InternalLuceneIndex extends LuceneIndex {
+  
+  public RepositoryManager getRepositoryManager();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneService.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneService.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneService.java
new file mode 100644
index 0000000..d09ef19
--- /dev/null
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneService.java
@@ -0,0 +1,9 @@
+package com.gemstone.gemfire.cache.lucene.internal;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.lucene.LuceneService;
+import com.gemstone.gemfire.internal.cache.extension.Extension;
+
+public interface InternalLuceneService extends LuceneService, Extension<Cache> {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java
index 799ef27..1a91292 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java
@@ -7,12 +7,11 @@ import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 
 import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.lucene.LuceneIndex;
 import com.gemstone.gemfire.cache.lucene.internal.filesystem.ChunkKey;
 import com.gemstone.gemfire.cache.lucene.internal.filesystem.File;
 import com.gemstone.gemfire.cache.lucene.internal.repository.RepositoryManager;
 
-public abstract class LuceneIndexImpl implements LuceneIndex {
+public abstract class LuceneIndexImpl implements InternalLuceneIndex {
 
   static private final boolean CREATE_CACHE = Boolean.getBoolean("lucene.createCache");
   static private final boolean USE_FS = Boolean.getBoolean("lucene.useFileSystem");

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryFactoryImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryFactoryImpl.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryFactoryImpl.java
index f5d38bc..9210929 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryFactoryImpl.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryFactoryImpl.java
@@ -15,9 +15,9 @@ import com.gemstone.gemfire.cache.lucene.LuceneQueryFactory;
 import com.gemstone.gemfire.cache.lucene.LuceneQueryProvider;
 
 public class LuceneQueryFactoryImpl implements LuceneQueryFactory {
-  private int limit_attr = DEFAULT_LIMIT;
-  private int pageSize_attr = DEFAULT_PAGESIZE;
-  private Set<String> projection_fields_attr = new HashSet<String>();
+  private int limit = DEFAULT_LIMIT;
+  private int pageSize = DEFAULT_PAGESIZE;
+  private Set<String> projectionFields = new HashSet<String>();
   
   /* reference to the index. One index could have multiple Queries, but one Query must belong
    * to one index
@@ -26,38 +26,25 @@ public class LuceneQueryFactoryImpl implements LuceneQueryFactory {
 
   @Override
   public LuceneQueryFactory setPageSize(int pageSize) {
-    this.pageSize_attr = pageSize;
+    this.pageSize = pageSize;
     return this;
   }
 
   @Override
   public LuceneQueryFactory setResultLimit(int limit) {
-    this.limit_attr = limit;
+    this.limit = limit;
     return this;
   }
 
   @Override
   public LuceneQuery create(String indexName, String regionName,
-      String queryString, Analyzer analyzer) throws ParseException {
-    QueryParser parser = new QueryParser(null, analyzer);
-    Query query = parser.parse(queryString);
-    LuceneQueryImpl luceneQuery = new LuceneQueryImpl(indexName, regionName, limit_attr, pageSize_attr, projection_fields_attr, query);
-    return luceneQuery;
-  }
-
-  @Override
-  public LuceneQuery create(String indexName, String regionName,
       String queryString) throws ParseException {
-    StandardAnalyzer analyzer = new StandardAnalyzer();
-    return create(indexName, regionName, queryString, analyzer);
+    return create(indexName, regionName, new StringQueryProvider(queryString));
   }
   
   public LuceneQuery create(String indexName, String regionName, LuceneQueryProvider provider) {
-//    LuceneQueryImpl luceneQuery = new LuceneQueryImpl(indexName, regionName, limit_attr, pageSize_attr, 
-//        resultType_attr, projection_fields_attr, query);
-//    return luceneQuery;
-    // TODO Auto-generated method stub
-    return null;
+    LuceneQueryImpl luceneQuery = new LuceneQueryImpl(indexName, regionName, provider, projectionFields, limit, pageSize);
+    return luceneQuery;
   }
   
 
@@ -69,7 +56,7 @@ public class LuceneQueryFactoryImpl implements LuceneQueryFactory {
   public LuceneQueryFactory setProjectionFields(String... fieldNames) {
     if (fieldNames != null) {
       for (String fieldName:fieldNames) {
-        this.projection_fields_attr.add(fieldName);
+        this.projectionFields.add(fieldName);
       }
     }
     return this;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryImpl.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryImpl.java
index e93692f..714df95 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryImpl.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryImpl.java
@@ -6,6 +6,7 @@ import org.apache.lucene.search.Query;
 
 import com.gemstone.gemfire.cache.lucene.LuceneQuery;
 import com.gemstone.gemfire.cache.lucene.LuceneQueryFactory;
+import com.gemstone.gemfire.cache.lucene.LuceneQueryProvider;
 import com.gemstone.gemfire.cache.lucene.LuceneQueryResults;
 
 public class LuceneQueryImpl implements LuceneQuery {
@@ -18,16 +19,16 @@ public class LuceneQueryImpl implements LuceneQuery {
   private Set<String> projectedFieldNames;
   
   /* the lucene Query object to be wrapped here */
-  private Query query;
+  private LuceneQueryProvider query;
   
-  LuceneQueryImpl(String indexName, String regionName, int limit, int pageSize, 
-      Set<String> projectionFieldNames, Query query) {
+  LuceneQueryImpl(String indexName, String regionName, LuceneQueryProvider provider, Set<String> projectionFields, 
+      int limit, int pageSize) {
     this.indexName = indexName;
     this.regionName = regionName;
     this.limit = limit;
     this.pageSize = pageSize;
-    this.projectedFieldNames = projectionFieldNames;
-    this.query = query;
+    this.projectedFieldNames = projectionFields;
+    this.query = provider;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java
index 1d7178a..cb6e5fc 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java
@@ -14,7 +14,6 @@ import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.execute.FunctionService;
 import com.gemstone.gemfire.cache.lucene.LuceneIndex;
 import com.gemstone.gemfire.cache.lucene.LuceneQueryFactory;
-import com.gemstone.gemfire.cache.lucene.LuceneService;
 import com.gemstone.gemfire.cache.lucene.internal.distributed.EntryScore;
 import com.gemstone.gemfire.cache.lucene.internal.distributed.LuceneFunction;
 import com.gemstone.gemfire.cache.lucene.internal.distributed.LuceneFunctionContext;
@@ -28,7 +27,6 @@ import com.gemstone.gemfire.internal.DataSerializableFixedID;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.extension.Extensible;
-import com.gemstone.gemfire.internal.cache.extension.Extension;
 import com.gemstone.gemfire.internal.cache.xmlcache.XmlGenerator;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
@@ -40,7 +38,7 @@ import com.gemstone.gemfire.internal.logging.LogService;
  * 
  * @since 8.5
  */
-public class LuceneServiceImpl implements LuceneService, Extension<Cache> {
+public class LuceneServiceImpl implements InternalLuceneService {
   private final Cache cache;
 
   private final HashMap<String, LuceneIndex> indexMap;
@@ -80,7 +78,7 @@ public class LuceneServiceImpl implements LuceneService, Extension<Cache> {
     // for this API, set index to use the default StandardAnalyzer for each field
     index.setAnalyzer(null);
     index.initialize();
-    registerIndex(getUniqueIndexName(indexName, regionPath), index);
+    registerIndex(index);
     return index;
   }
   
@@ -90,6 +88,9 @@ public class LuceneServiceImpl implements LuceneService, Extension<Cache> {
       logger.info("Data region "+regionPath+" not found");
       return null;
     }
+    //Convert the region name into a canonical form
+    
+    regionPath = dataregion.getFullPath();
     LuceneIndexImpl index = null;
     if (dataregion instanceof PartitionedRegion) {
       // partitioned region
@@ -103,7 +104,11 @@ public class LuceneServiceImpl implements LuceneService, Extension<Cache> {
 
   @Override
   public LuceneIndex getIndex(String indexName, String regionPath) {
-    return indexMap.get(getUniqueIndexName(indexName, regionPath));
+    Region region = cache.getRegion(regionPath);
+    if(region == null) {
+      return null;
+    }
+    return indexMap.get(getUniqueIndexName(indexName, region.getFullPath()));
   }
 
   @Override
@@ -124,7 +129,7 @@ public class LuceneServiceImpl implements LuceneService, Extension<Cache> {
     }
     index.setAnalyzer(analyzer);
     index.initialize();
-    registerIndex(getUniqueIndexName(indexName, regionPath), index);
+    registerIndex(index);
     return index;
   }
 
@@ -152,7 +157,8 @@ public class LuceneServiceImpl implements LuceneService, Extension<Cache> {
 
   }
   
-  public void registerIndex(final String regionAndIndex, LuceneIndex index){
+  public void registerIndex(LuceneIndex index){
+    String regionAndIndex = getUniqueIndexName(index.getName(), index.getRegionPath()); 
     if( !indexMap.containsKey( regionAndIndex )) {
       indexMap.put(regionAndIndex, index);
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManager.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManager.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManager.java
index 65c678c..91ad82c 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManager.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManager.java
@@ -11,15 +11,19 @@ import org.apache.lucene.index.IndexWriterConfig;
 
 import com.gemstone.gemfire.InternalGemFireError;
 import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.execute.RegionFunctionContext;
 import com.gemstone.gemfire.cache.lucene.internal.directory.RegionDirectory;
 import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepository;
 import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepositoryImpl;
 import com.gemstone.gemfire.cache.lucene.internal.repository.RepositoryManager;
 import com.gemstone.gemfire.cache.lucene.internal.repository.serializer.LuceneSerializer;
+import com.gemstone.gemfire.cache.partition.PartitionRegionHelper;
 import com.gemstone.gemfire.internal.cache.BucketNotFoundException;
 import com.gemstone.gemfire.internal.cache.BucketRegion;
 import com.gemstone.gemfire.internal.cache.LocalDataSet;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
+import com.gemstone.gemfire.internal.cache.PartitionedRegionHelper;
+import com.gemstone.gemfire.internal.cache.execute.InternalRegionFunctionContext;
 import com.gemstone.gemfire.internal.util.concurrent.CopyOnWriteHashMap;
 
 /**
@@ -77,13 +81,10 @@ public class PartitionedRepositoryManager implements RepositoryManager {
   }
   
   @Override
-  public Collection<IndexRepository> getRepositories(Region region) throws BucketNotFoundException {
-    if(!(region instanceof LocalDataSet)) {
-      throw new IllegalStateException("Trying to find the repositories for a region which is not the local data set of a function");
-    }
+  public Collection<IndexRepository> getRepositories(RegionFunctionContext ctx) throws BucketNotFoundException {
     
-    LocalDataSet dataSet = (LocalDataSet) region;
-    Set<Integer> buckets = dataSet.getBucketSet();
+    Region<Object, Object> region = ctx.getDataSet();
+    Set<Integer> buckets = ((InternalRegionFunctionContext) ctx).getLocalBucketSet(region);
     ArrayList<IndexRepository> repos = new ArrayList<IndexRepository>(buckets.size());
     for(Integer bucketId : buckets) {
       BucketRegion userBucket = userRegion.getDataStore().getLocalBucketById(bucketId);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProvider.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProvider.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProvider.java
index 78a2f99..7e50bae 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProvider.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProvider.java
@@ -6,6 +6,7 @@ import java.io.IOException;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.lucene.analysis.core.SimpleAnalyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
 import org.apache.lucene.queryparser.classic.ParseException;
 import org.apache.lucene.search.Query;
@@ -29,37 +30,25 @@ public class StringQueryProvider implements LuceneQueryProvider, DataSerializabl
 
   // the following members hold input data and needs to be sent on wire
   private String query;
-  private String indexName;
-  private String regionPath;
 
   // the following members hold derived objects and need not be serialized
-  private Query luceneQuery;
-  private LuceneIndex index;
+  private transient Query luceneQuery;
 
   public StringQueryProvider() {
-    this(null, null);
+    this(null);
   }
 
-  public StringQueryProvider(LuceneIndex index, String query) {
+  public StringQueryProvider(String query) {
     this.query = query;
-    this.index = index;
-    if (index != null) {
-      this.indexName = index.getName();
-      this.regionPath = index.getRegionPath();
-    }
   }
 
   @Override
-  public synchronized Query getQuery() throws QueryException {
+  public synchronized Query getQuery(LuceneIndex index) throws QueryException {
     if (luceneQuery == null) {
-      String[] fields = null;
-      if (index != null) {
-        fields = index.getFieldNames();
-      } else {
-        // TODO get index from lucene query service
-      }
+      String[] fields = index.getFieldNames();
 
-      MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new SimpleAnalyzer());
+      //TODO  get the analyzer from the index
+      MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
       try {
         luceneQuery = parser.parse(query);
       } catch (ParseException e) {
@@ -77,20 +66,6 @@ public class StringQueryProvider implements LuceneQueryProvider, DataSerializabl
     return query;
   }
 
-  /**
-   * @return name of the index on which this query will be executed
-   */
-  public String getIndexName() {
-    return indexName;
-  }
-
-  /**
-   * @return path of the region on which this query will be executed
-   */
-  public String getRegionPath() {
-    return regionPath;
-  }
-
   @Override
   public Version[] getSerializationVersions() {
     return null;
@@ -104,14 +79,10 @@ public class StringQueryProvider implements LuceneQueryProvider, DataSerializabl
   @Override
   public void toData(DataOutput out) throws IOException {
     DataSerializer.writeString(query, out);
-    DataSerializer.writeString(index.getName(), out);
-    DataSerializer.writeString(index.getRegionPath(), out);
   }
 
   @Override
   public void fromData(DataInput in) throws IOException, ClassNotFoundException {
     query = DataSerializer.readString(in);
-    this.indexName = DataSerializer.readString(in);
-    this.regionPath = DataSerializer.readString(in);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunction.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunction.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunction.java
index ca0e2d3..b8552fa 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunction.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunction.java
@@ -14,6 +14,9 @@ import com.gemstone.gemfire.cache.execute.RegionFunctionContext;
 import com.gemstone.gemfire.cache.execute.ResultSender;
 import com.gemstone.gemfire.cache.lucene.LuceneQueryFactory;
 import com.gemstone.gemfire.cache.lucene.LuceneQueryProvider;
+import com.gemstone.gemfire.cache.lucene.LuceneService;
+import com.gemstone.gemfire.cache.lucene.LuceneServiceProvider;
+import com.gemstone.gemfire.cache.lucene.internal.InternalLuceneIndex;
 import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepository;
 import com.gemstone.gemfire.cache.lucene.internal.repository.IndexResultCollector;
 import com.gemstone.gemfire.cache.lucene.internal.repository.RepositoryManager;
@@ -32,8 +35,6 @@ public class LuceneFunction extends FunctionAdapter {
 
   private static final Logger logger = LogService.getLogger();
 
-  private static RepositoryManager repoManager;
-
   @Override
   public void execute(FunctionContext context) {
     RegionFunctionContext ctx = (RegionFunctionContext) context;
@@ -52,10 +53,14 @@ public class LuceneFunction extends FunctionAdapter {
       resultSender.sendException(new IllegalArgumentException("Missing query provider"));
       return;
     }
+    
+    LuceneService service = LuceneServiceProvider.get(region.getCache());
+    InternalLuceneIndex index = (InternalLuceneIndex) service.getIndex(searchContext.getIndexName(), region.getFullPath());
+    RepositoryManager repoManager = index.getRepositoryManager();
 
     Query query = null;
     try {
-      query = queryProvider.getQuery();
+      query = queryProvider.getQuery(index);
     } catch (QueryException e) {
       resultSender.sendException(e);
       return;
@@ -65,19 +70,19 @@ public class LuceneFunction extends FunctionAdapter {
       logger.debug("Executing lucene query: {}, on region {}", query, region.getFullPath());
     }
 
+    int resultLimit = searchContext.getLimit();
     CollectorManager manager = (searchContext == null) ? null : searchContext.getCollectorManager();
     if (manager == null) {
-      int resultLimit = (searchContext == null ? LuceneQueryFactory.DEFAULT_LIMIT : searchContext.getLimit());
       manager = new TopEntriesCollectorManager(null, resultLimit);
     }
 
     Collection<IndexResultCollector> results = new ArrayList<>();
     try {
-      Collection<IndexRepository> repositories = getIndexRepositories(ctx, region);
+      Collection<IndexRepository> repositories = repoManager.getRepositories(ctx);
       for (IndexRepository repo : repositories) {
         IndexResultCollector collector = manager.newCollector(repo.toString());
         logger.debug("Executing search on repo: " + repo.toString());
-        repo.query(query, 0, collector);
+        repo.query(query, resultLimit, collector);
         results.add(collector);
       }
     } catch (IOException e) {
@@ -101,15 +106,6 @@ public class LuceneFunction extends FunctionAdapter {
     }
   }
 
-  private Collection<IndexRepository> getIndexRepositories(RegionFunctionContext ctx, Region region) throws BucketNotFoundException {
-    synchronized (LuceneFunction.class) {
-      return repoManager.getRepositories(region);
-    }
-  }
-
-  static synchronized void setRepositoryManager(RepositoryManager manager) {
-    repoManager = manager;
-  }
 
   @Override
   public String getId() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionContext.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionContext.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionContext.java
index feeb768..d36bcc2 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionContext.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionContext.java
@@ -18,23 +18,24 @@ import com.gemstone.gemfire.internal.Version;
 public class LuceneFunctionContext<C extends IndexResultCollector> implements DataSerializableFixedID {
   private CollectorManager<C> manager;
   private int limit;
-
-  LuceneQueryProvider queryProvider;
+  private LuceneQueryProvider queryProvider;
+  private String indexName;
 
   public LuceneFunctionContext() {
-    this(null, null);
+    this(null, null, null);
   }
 
-  public LuceneFunctionContext(LuceneQueryProvider provider) {
-    this(provider, null);
+  public LuceneFunctionContext(LuceneQueryProvider provider, String indexName) {
+    this(provider, indexName, null);
   }
 
-  public LuceneFunctionContext(LuceneQueryProvider provider, CollectorManager<C> manager) {
-    this(provider, manager, LuceneQueryFactory.DEFAULT_LIMIT);
+  public LuceneFunctionContext(LuceneQueryProvider provider, String indexName, CollectorManager<C> manager) {
+    this(provider, indexName, manager, LuceneQueryFactory.DEFAULT_LIMIT);
   }
 
-  public LuceneFunctionContext(LuceneQueryProvider provider, CollectorManager<C> manager, int limit) {
+  public LuceneFunctionContext(LuceneQueryProvider provider, String indexName, CollectorManager<C> manager, int limit) {
     this.queryProvider = provider;
+    this.indexName = indexName;
     this.manager = manager;
     this.limit = limit;
   }
@@ -47,6 +48,13 @@ public class LuceneFunctionContext<C extends IndexResultCollector> implements Da
   }
 
   /**
+   * Get the name of the index to query
+   */
+  public String getIndexName() {
+    return indexName;
+  }
+
+  /**
    * On each member, search query is executed on one or more {@link IndexRepository}s. A {@link CollectorManager} could
    * be provided to customize the way results from these repositories is collected and merged.
    * 
@@ -70,6 +78,7 @@ public class LuceneFunctionContext<C extends IndexResultCollector> implements Da
     out.writeInt(limit);
     DataSerializer.writeObject(queryProvider, out);
     DataSerializer.writeObject(manager, out);
+    DataSerializer.writeString(indexName, out);
   }
 
   @Override
@@ -77,6 +86,7 @@ public class LuceneFunctionContext<C extends IndexResultCollector> implements Da
     limit = in.readInt();
     queryProvider = DataSerializer.readObject(in);
     manager = DataSerializer.readObject(in);
+    this.indexName = DataSerializer.readString(in);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/repository/RepositoryManager.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/repository/RepositoryManager.java b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/repository/RepositoryManager.java
index b61e8be..cea4f89 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/repository/RepositoryManager.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/repository/RepositoryManager.java
@@ -22,5 +22,5 @@ public interface RepositoryManager {
    * @return a collection of {@link IndexRepository} instances
    * @throws BucketNotFoundException if any of the requested buckets is not found on this member
    */
-  Collection<IndexRepository> getRepositories(Region localDataSet) throws BucketNotFoundException;
+  Collection<IndexRepository> getRepositories(RegionFunctionContext context) throws BucketNotFoundException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImplJUnitTest.java b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImplJUnitTest.java
index a7ed00d..10f4794 100644
--- a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImplJUnitTest.java
+++ b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImplJUnitTest.java
@@ -127,7 +127,7 @@ public class LuceneServiceImplJUnitTest {
     assertTrue(index1 instanceof LuceneIndexForPartitionedRegion);
     LuceneIndexForPartitionedRegion index1PR = (LuceneIndexForPartitionedRegion)index1;
     assertEquals("index1", index1.getName());
-    assertEquals("PR1", index1.getRegionPath());
+    assertEquals("/PR1", index1.getRegionPath());
     String[] fields1 = index1.getFieldNames();
     assertEquals(3, fields1.length);
     Analyzer analyzer = index1PR.getAnalyzer();
@@ -135,8 +135,8 @@ public class LuceneServiceImplJUnitTest {
     RepositoryManager RepositoryManager = index1PR.getRepositoryManager();
     assertTrue(RepositoryManager != null);
    
-    final String fileRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "PR1")+".files";
-    final String chunkRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "PR1")+".chunks";
+    final String fileRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "/PR1")+".files";
+    final String chunkRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "/PR1")+".chunks";
     PartitionedRegion filePR = (PartitionedRegion)cache.getRegion(fileRegionName);
     PartitionedRegion chunkPR = (PartitionedRegion)cache.getRegion(chunkRegionName);
     assertTrue(filePR != null);
@@ -160,7 +160,7 @@ public class LuceneServiceImplJUnitTest {
     assertTrue(index1 instanceof LuceneIndexForPartitionedRegion);
     LuceneIndexForPartitionedRegion index1PR = (LuceneIndexForPartitionedRegion)index1;
     assertEquals("index1", index1.getName());
-    assertEquals("PR1", index1.getRegionPath());
+    assertEquals("/PR1", index1.getRegionPath());
     String[] fields1 = index1.getFieldNames();
     assertEquals(3, fields1.length);
     Analyzer analyzer = index1PR.getAnalyzer();
@@ -168,8 +168,8 @@ public class LuceneServiceImplJUnitTest {
     RepositoryManager RepositoryManager = index1PR.getRepositoryManager();
     assertTrue(RepositoryManager != null);
    
-    final String fileRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "PR1")+".files";
-    final String chunkRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "PR1")+".chunks";
+    final String fileRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "/PR1")+".files";
+    final String chunkRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "/PR1")+".chunks";
     PartitionedRegion filePR = (PartitionedRegion)cache.getRegion(fileRegionName);
     PartitionedRegion chunkPR = (PartitionedRegion)cache.getRegion(chunkRegionName);
     assertTrue(filePR != null);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
index a2cc75e..1225aa1 100644
--- a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
+++ b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
@@ -2,6 +2,7 @@ package com.gemstone.gemfire.cache.lucene.internal;
 
 import static org.junit.Assert.*;
 import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
 
 import java.io.IOException;
 import java.util.Arrays;
@@ -21,6 +22,7 @@ import org.mockito.Mockito;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
+import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.lucene.internal.directory.RegionDirectory;
 import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepository;
 import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepositoryImpl;
@@ -32,6 +34,7 @@ import com.gemstone.gemfire.internal.cache.LocalDataSet;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion.RetryTimeKeeper;
 import com.gemstone.gemfire.internal.cache.PartitionedRegionDataStore;
+import com.gemstone.gemfire.internal.cache.execute.InternalRegionFunctionContext;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 @Category(UnitTest.class)
@@ -147,8 +150,9 @@ public class PartitionedRepositoryManagerJUnitTest {
     BucketRegion mockBucket1 = getMockBucket(1);
 
     Set<Integer> buckets = new LinkedHashSet<Integer>(Arrays.asList(0, 1));
-    LocalDataSet ldr = new LocalDataSet(null, buckets);
-    Collection<IndexRepository> repos = repoManager.getRepositories(ldr);
+    InternalRegionFunctionContext ctx = Mockito.mock(InternalRegionFunctionContext.class);
+    Mockito.when(ctx.getLocalBucketSet((any(Region.class)))).thenReturn(buckets);
+    Collection<IndexRepository> repos = repoManager.getRepositories(ctx);
     assertEquals(2, repos.size());
 
     Iterator<IndexRepository> itr = repos.iterator();
@@ -173,9 +177,10 @@ public class PartitionedRepositoryManagerJUnitTest {
     BucketRegion mockBucket0 = getMockBucket(0);
 
     Set<Integer> buckets = new LinkedHashSet<Integer>(Arrays.asList(0, 1));
-    LocalDataSet ldr = new LocalDataSet(userRegion, buckets);
 
-    repoManager.getRepositories(ldr);
+    InternalRegionFunctionContext ctx = Mockito.mock(InternalRegionFunctionContext.class);
+    Mockito.when(ctx.getLocalBucketSet((any(Region.class)))).thenReturn(buckets);
+    repoManager.getRepositories(ctx);
   }
   
   private void checkRepository(IndexRepositoryImpl repo0, int bucketId) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProviderJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProviderJUnitTest.java b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProviderJUnitTest.java
index 078ae42..673fdf2 100644
--- a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProviderJUnitTest.java
+++ b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProviderJUnitTest.java
@@ -5,6 +5,7 @@ import static org.junit.Assert.assertEquals;
 import org.apache.lucene.search.Query;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.mockito.Mockito;
@@ -31,41 +32,40 @@ public class StringQueryProviderJUnitTest {
 
   @Test
   public void testQueryConstruction() throws QueryException {
-    StringQueryProvider provider = new StringQueryProvider(null, "foo:bar");
-    Query query = provider.getQuery();
+    StringQueryProvider provider = new StringQueryProvider("foo:bar");
+    Query query = provider.getQuery(mockIndex);
     Assert.assertNotNull(query);
     assertEquals("foo:bar", query.toString());
   }
 
   @Test
   public void usesSearchableFieldsAsDefaults() throws QueryException {
-    StringQueryProvider provider = new StringQueryProvider(mockIndex, "findThis");
-    Query query = provider.getQuery();
+    StringQueryProvider provider = new StringQueryProvider("findThis");
+    Query query = provider.getQuery(mockIndex);
     Assert.assertNotNull(query);
     assertEquals("field-1:findthis field-2:findthis", query.toString());
   }
 
   @Test
+  @Ignore("Custom analyzer not yet supported, this is a duplicate test right now")
   public void usesCustomAnalyzer() throws QueryException {
-    StringQueryProvider provider = new StringQueryProvider(mockIndex, "findThis");
-    Query query = provider.getQuery();
+    StringQueryProvider provider = new StringQueryProvider("findThis");
+    Query query = provider.getQuery(mockIndex);
     Assert.assertNotNull(query);
     assertEquals("field-1:findthis field-2:findthis", query.toString());
   }
 
   @Test(expected = QueryException.class)
   public void errorsOnMalformedQueryString() throws QueryException {
-    StringQueryProvider provider = new StringQueryProvider(mockIndex, "invalid:lucene:query:string");
-    provider.getQuery();
+    StringQueryProvider provider = new StringQueryProvider("invalid:lucene:query:string");
+    provider.getQuery(mockIndex);
   }
   
   @Test
   public void testSerialization() {
     LuceneServiceImpl.registerDataSerializables();
-    StringQueryProvider provider = new StringQueryProvider(mockIndex, "text:search");
+    StringQueryProvider provider = new StringQueryProvider("text:search");
     StringQueryProvider copy = CopyHelper.deepCopy(provider);
     assertEquals("text:search", copy.getQueryString());
-    assertEquals(mockIndex.getName(), copy.getIndexName());
-    assertEquals(mockIndex.getRegionPath(), copy.getRegionPath());
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionContextJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionContextJUnitTest.java b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionContextJUnitTest.java
index 01a1690..98b48d8 100644
--- a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionContextJUnitTest.java
+++ b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionContextJUnitTest.java
@@ -30,18 +30,16 @@ public class LuceneFunctionContextJUnitTest {
   public void testSerialization() {
     LuceneServiceImpl.registerDataSerializables();
 
-    LuceneIndex mockIndex = Mockito.mock(LuceneIndex.class);
-    Mockito.doReturn("mockIndex").when(mockIndex).getName();
-    LuceneQueryProvider provider = new StringQueryProvider(mockIndex, "text");
+    LuceneQueryProvider provider = new StringQueryProvider("text");
     CollectorManager<TopEntriesCollector> manager = new TopEntriesCollectorManager("test");
-    LuceneFunctionContext<TopEntriesCollector> context = new LuceneFunctionContext<>(provider, manager, 123);
+    LuceneFunctionContext<TopEntriesCollector> context = new LuceneFunctionContext<>(provider, "testIndex", manager, 123);
 
     LuceneFunctionContext<TopEntriesCollector> copy = CopyHelper.deepCopy(context);
     assertEquals(123, copy.getLimit());
     Assert.assertNotNull(copy.getQueryProvider());
     assertEquals("text", ((StringQueryProvider) copy.getQueryProvider()).getQueryString());
-    assertEquals("mockIndex", ((StringQueryProvider) copy.getQueryProvider()).getIndexName());
     assertEquals(TopEntriesCollectorManager.class, copy.getCollectorManager().getClass());
     assertEquals("test", ((TopEntriesCollectorManager) copy.getCollectorManager()).getId());
+    assertEquals("testIndex", copy.getIndexName());
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionJUnitTest.java b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionJUnitTest.java
index ba5f96a..6c37468 100644
--- a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionJUnitTest.java
+++ b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionJUnitTest.java
@@ -1,6 +1,6 @@
 package com.gemstone.gemfire.cache.lucene.internal.distributed;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -23,26 +23,35 @@ import org.junit.experimental.categories.Category;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.execute.RegionFunctionContext;
 import com.gemstone.gemfire.cache.execute.ResultSender;
+import com.gemstone.gemfire.cache.lucene.LuceneQueryFactory;
 import com.gemstone.gemfire.cache.lucene.LuceneQueryProvider;
+import com.gemstone.gemfire.cache.lucene.LuceneService;
+import com.gemstone.gemfire.cache.lucene.internal.InternalLuceneIndex;
+import com.gemstone.gemfire.cache.lucene.internal.InternalLuceneService;
 import com.gemstone.gemfire.cache.lucene.internal.StringQueryProvider;
 import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepository;
 import com.gemstone.gemfire.cache.lucene.internal.repository.IndexResultCollector;
 import com.gemstone.gemfire.cache.lucene.internal.repository.RepositoryManager;
 import com.gemstone.gemfire.cache.query.QueryException;
 import com.gemstone.gemfire.internal.cache.BucketNotFoundException;
+import com.gemstone.gemfire.internal.cache.InternalCache;
+import com.gemstone.gemfire.internal.cache.execute.InternalRegionFunctionContext;
+import com.gemstone.gemfire.internal.cache.extension.ExtensionPoint;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 @Category(UnitTest.class)
 public class LuceneFunctionJUnitTest {
   Mockery mocker;
 
+  String regionPath = "/region";
+  String indexName = "index";
   final EntryScore r1_1 = new EntryScore("key-1-1", .5f);
   final EntryScore r1_2 = new EntryScore("key-1-2", .4f);
   final EntryScore r1_3 = new EntryScore("key-1-3", .3f);
   final EntryScore r2_1 = new EntryScore("key-2-1", .45f);
   final EntryScore r2_2 = new EntryScore("key-2-2", .35f);
 
-  RegionFunctionContext mockContext;
+  InternalRegionFunctionContext mockContext;
   ResultSender<TopEntriesCollector> mockResultSender;
   Region<Object, Object> mockRegion;
 
@@ -50,12 +59,16 @@ public class LuceneFunctionJUnitTest {
   IndexRepository mockRepository1;
   IndexRepository mockRepository2;
   IndexResultCollector mockCollector;
+  InternalLuceneService mockService;
+  InternalLuceneIndex mockIndex;
 
   ArrayList<IndexRepository> repos;
   LuceneFunctionContext searchArgs;
   LuceneQueryProvider queryProvider;
   Query query;
 
+  private InternalCache mockCache;
+
   @Test
   public void testRepoQueryAndMerge() throws Exception {
     final AtomicReference<TopEntriesCollector> result = new AtomicReference<>();
@@ -66,13 +79,13 @@ public class LuceneFunctionJUnitTest {
         oneOf(mockContext).getArguments();
         will(returnValue(searchArgs));
 
-        oneOf(mockRepoManager).getRepositories(mockRegion);
+        oneOf(mockRepoManager).getRepositories(mockContext);
         will(returnValue(repos));
 
         oneOf(mockContext).getResultSender();
         will(returnValue(mockResultSender));
 
-        oneOf(mockRepository1).query(with(query), with(equal(0)), with(any(IndexResultCollector.class)));
+        oneOf(mockRepository1).query(with(query), with(equal(LuceneQueryFactory.DEFAULT_LIMIT)), with(any(IndexResultCollector.class)));
         will(new CustomAction("streamSearchResults") {
           @Override
           public Object invoke(Invocation invocation) throws Throwable {
@@ -84,7 +97,7 @@ public class LuceneFunctionJUnitTest {
           }
         });
 
-        oneOf(mockRepository2).query(with(query), with(equal(0)), with(any(IndexResultCollector.class)));
+        oneOf(mockRepository2).query(with(query), with(equal(LuceneQueryFactory.DEFAULT_LIMIT)), with(any(IndexResultCollector.class)));
         will(new CustomAction("streamSearchResults") {
           @Override
           public Object invoke(Invocation invocation) throws Throwable {
@@ -107,7 +120,6 @@ public class LuceneFunctionJUnitTest {
     });
 
     LuceneFunction function = new LuceneFunction();
-    function.setRepositoryManager(mockRepoManager);
 
     function.execute(mockContext);
     List<EntryScore> hits = result.get().getEntries().getHits();
@@ -119,7 +131,7 @@ public class LuceneFunctionJUnitTest {
   public void testResultLimitClause() throws Exception {
     final AtomicReference<TopEntriesCollector> result = new AtomicReference<>();
 
-    searchArgs = new LuceneFunctionContext<IndexResultCollector>(queryProvider, null, 3);
+    searchArgs = new LuceneFunctionContext<IndexResultCollector>(queryProvider, "indexName", null, 3);
 
     mocker.checking(new Expectations() {
       {
@@ -131,10 +143,10 @@ public class LuceneFunctionJUnitTest {
         oneOf(mockContext).getResultSender();
         will(returnValue(mockResultSender));
 
-        oneOf(mockRepoManager).getRepositories(mockRegion);
+        oneOf(mockRepoManager).getRepositories(mockContext);
         will(returnValue(repos));
 
-        oneOf(mockRepository1).query(with(query), with(equal(0)), with(any(IndexResultCollector.class)));
+        oneOf(mockRepository1).query(with(query), with(equal(3)), with(any(IndexResultCollector.class)));
         will(new CustomAction("streamSearchResults") {
           @Override
           public Object invoke(Invocation invocation) throws Throwable {
@@ -146,7 +158,7 @@ public class LuceneFunctionJUnitTest {
           }
         });
 
-        oneOf(mockRepository2).query(with(query), with(equal(0)), with(any(IndexResultCollector.class)));
+        oneOf(mockRepository2).query(with(query), with(equal(3)), with(any(IndexResultCollector.class)));
         will(new CustomAction("streamSearchResults") {
           @Override
           public Object invoke(Invocation invocation) throws Throwable {
@@ -169,7 +181,6 @@ public class LuceneFunctionJUnitTest {
     });
 
     LuceneFunction function = new LuceneFunction();
-    function.setRepositoryManager(mockRepoManager);
 
     function.execute(mockContext);
     List<EntryScore> hits = result.get().getEntries().getHits();
@@ -180,7 +191,7 @@ public class LuceneFunctionJUnitTest {
   @Test
   public void injectCustomCollectorManager() throws Exception {
     final CollectorManager mockManager = mocker.mock(CollectorManager.class);
-    searchArgs = new LuceneFunctionContext<IndexResultCollector>(queryProvider, mockManager);
+    searchArgs = new LuceneFunctionContext<IndexResultCollector>(queryProvider, "indexName", mockManager);
     mocker.checking(new Expectations() {
       {
         oneOf(mockContext).getDataSet();
@@ -190,7 +201,7 @@ public class LuceneFunctionJUnitTest {
         oneOf(mockContext).getResultSender();
         will(returnValue(mockResultSender));
 
-        oneOf(mockRepoManager).getRepositories(mockRegion);
+        oneOf(mockRepoManager).getRepositories(mockContext);
         repos.remove(0);
         will(returnValue(repos));
 
@@ -209,7 +220,7 @@ public class LuceneFunctionJUnitTest {
 
         oneOf(mockCollector).collect("key-2-1", .45f);
 
-        oneOf(mockRepository2).query(with(query), with(equal(0)), with(any(IndexResultCollector.class)));
+        oneOf(mockRepository2).query(with(query), with(equal(LuceneQueryFactory.DEFAULT_LIMIT)), with(any(IndexResultCollector.class)));
         will(new CustomAction("streamSearchResults") {
           @Override
           public Object invoke(Invocation invocation) throws Throwable {
@@ -224,7 +235,6 @@ public class LuceneFunctionJUnitTest {
     });
 
     LuceneFunction function = new LuceneFunction();
-    function.setRepositoryManager(mockRepoManager);
 
     function.execute(mockContext);
   }
@@ -238,20 +248,19 @@ public class LuceneFunctionJUnitTest {
         oneOf(mockContext).getArguments();
         will(returnValue(searchArgs));
 
-        oneOf(mockRepoManager).getRepositories(mockRegion);
+        oneOf(mockRepoManager).getRepositories(mockContext);
         will(returnValue(repos));
 
         oneOf(mockContext).getResultSender();
         will(returnValue(mockResultSender));
         oneOf(mockResultSender).sendException(with(any(IOException.class)));
 
-        oneOf(mockRepository1).query(with(query), with(equal(0)), with(any(IndexResultCollector.class)));
+        oneOf(mockRepository1).query(with(query), with(equal(LuceneQueryFactory.DEFAULT_LIMIT)), with(any(IndexResultCollector.class)));
         will(throwException(new IOException()));
       }
     });
 
     LuceneFunction function = new LuceneFunction();
-    function.setRepositoryManager(mockRepoManager);
 
     function.execute(mockContext);
   }
@@ -265,7 +274,7 @@ public class LuceneFunctionJUnitTest {
         oneOf(mockContext).getArguments();
         will(returnValue(searchArgs));
 
-        oneOf(mockRepoManager).getRepositories(mockRegion);
+        oneOf(mockRepoManager).getRepositories(mockContext);
         will(throwException(new BucketNotFoundException("")));
 
         oneOf(mockContext).getResultSender();
@@ -275,7 +284,6 @@ public class LuceneFunctionJUnitTest {
     });
 
     LuceneFunction function = new LuceneFunction();
-    function.setRepositoryManager(mockRepoManager);
 
     function.execute(mockContext);
   }
@@ -283,7 +291,7 @@ public class LuceneFunctionJUnitTest {
   @Test
   public void testReduceError() throws Exception {
     final CollectorManager mockManager = mocker.mock(CollectorManager.class);
-    searchArgs = new LuceneFunctionContext<IndexResultCollector>(queryProvider, mockManager);
+    searchArgs = new LuceneFunctionContext<IndexResultCollector>(queryProvider, "indexName", mockManager);
     mocker.checking(new Expectations() {
       {
         oneOf(mockContext).getDataSet();
@@ -298,17 +306,16 @@ public class LuceneFunctionJUnitTest {
         oneOf(mockManager).reduce(with(any(Collection.class)));
         will(throwException(new IOException()));
 
-        oneOf(mockRepoManager).getRepositories(mockRegion);
+        oneOf(mockRepoManager).getRepositories(mockContext);
         repos.remove(1);
         will(returnValue(repos));
 
-        oneOf(mockRepository1).query(query, 0, mockCollector);
+        oneOf(mockRepository1).query(query, LuceneQueryFactory.DEFAULT_LIMIT, mockCollector);
         oneOf(mockResultSender).sendException(with(any(IOException.class)));
       }
     });
 
     LuceneFunction function = new LuceneFunction();
-    function.setRepositoryManager(mockRepoManager);
 
     function.execute(mockContext);
   }
@@ -316,7 +323,7 @@ public class LuceneFunctionJUnitTest {
   @Test
   public void queryProviderErrorIsHandled() throws Exception {
     queryProvider = mocker.mock(LuceneQueryProvider.class);
-    searchArgs = new LuceneFunctionContext<IndexResultCollector>(queryProvider, null);
+    searchArgs = new LuceneFunctionContext<IndexResultCollector>(queryProvider, "indexName");
     mocker.checking(new Expectations() {
       {
         oneOf(mockContext).getDataSet();
@@ -326,7 +333,7 @@ public class LuceneFunctionJUnitTest {
         oneOf(mockContext).getArguments();
         will(returnValue(searchArgs));
 
-        oneOf(queryProvider).getQuery();
+        oneOf(queryProvider).getQuery(mockIndex);
         will(throwException(new QueryException()));
 
         oneOf(mockResultSender).sendException(with(any(QueryException.class)));
@@ -334,7 +341,6 @@ public class LuceneFunctionJUnitTest {
     });
 
     LuceneFunction function = new LuceneFunction();
-    function.setRepositoryManager(mockRepoManager);
 
     function.execute(mockContext);
   }
@@ -354,7 +360,7 @@ public class LuceneFunctionJUnitTest {
       }
     };
 
-    mockContext = mocker.mock(RegionFunctionContext.class);
+    mockContext = mocker.mock(InternalRegionFunctionContext.class);
     mockResultSender = mocker.mock(ResultSender.class);
     mockRegion = mocker.mock(Region.class);
 
@@ -366,10 +372,35 @@ public class LuceneFunctionJUnitTest {
     repos = new ArrayList<IndexRepository>();
     repos.add(mockRepository1);
     repos.add(mockRepository2);
-
-    queryProvider = new StringQueryProvider(null, "gemfire:lucene");
-    query = queryProvider.getQuery();
-    searchArgs = new LuceneFunctionContext<IndexResultCollector>(queryProvider);
+    
+    mockIndex = mocker.mock(InternalLuceneIndex.class);
+    mockService = mocker.mock(InternalLuceneService.class);
+    mockCache = mocker.mock(InternalCache.class);
+
+    queryProvider = new StringQueryProvider("gemfire:lucene");
+    
+    searchArgs = new LuceneFunctionContext<IndexResultCollector>(queryProvider, "indexName");
+    
+    final ExtensionPoint mockExtensionPoint = mocker.mock(ExtensionPoint.class);
+    mocker.checking(new Expectations() {{
+      allowing(mockRegion).getCache();
+      will(returnValue(mockCache));
+      allowing(mockRegion).getFullPath();
+      will(returnValue(regionPath));
+      allowing(mockCache).getExtensionPoint();
+      will(returnValue(mockExtensionPoint));
+      allowing(mockExtensionPoint).getExtension(LuceneService.class);
+      will(returnValue(mockService));
+      allowing(mockService).getIndex(with("indexName"), with(regionPath));
+      will(returnValue(mockIndex));
+      allowing(mockIndex).getRepositoryManager();
+      will(returnValue(mockRepoManager));
+      allowing(mockIndex).getFieldNames();
+      will(returnValue(new String[] {"gemfire"}));
+      
+    }});
+    
+    query = queryProvider.getQuery(mockIndex);
   }
 
   @After

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java
index a950c8d..939790d 100644
--- a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java
+++ b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java
@@ -1,40 +1,30 @@
 package com.gemstone.gemfire.cache.lucene.internal.distributed;
 
-import static org.mockito.Matchers.*;
-import static org.mockito.Mockito.*;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
+import java.io.Serializable;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.lucene.search.Query;
 import org.junit.Assert;
 import org.junit.experimental.categories.Category;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.RegionFactory;
 import com.gemstone.gemfire.cache.RegionShortcut;
-import com.gemstone.gemfire.cache.execute.FunctionException;
 import com.gemstone.gemfire.cache.execute.FunctionService;
 import com.gemstone.gemfire.cache.execute.ResultCollector;
 import com.gemstone.gemfire.cache.lucene.LuceneIndex;
 import com.gemstone.gemfire.cache.lucene.LuceneQueryProvider;
 import com.gemstone.gemfire.cache.lucene.LuceneService;
 import com.gemstone.gemfire.cache.lucene.LuceneServiceProvider;
+import com.gemstone.gemfire.cache.lucene.internal.InternalLuceneIndex;
 import com.gemstone.gemfire.cache.lucene.internal.StringQueryProvider;
 import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepository;
-import com.gemstone.gemfire.cache.lucene.internal.repository.IndexResultCollector;
-import com.gemstone.gemfire.cache.lucene.internal.repository.RepositoryManager;
 import com.gemstone.gemfire.cache30.CacheTestCase;
 import com.gemstone.gemfire.internal.cache.BucketNotFoundException;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
 import dunit.Host;
+import dunit.SerializableCallable;
 import dunit.SerializableRunnable;
 import dunit.VM;
 
@@ -61,43 +51,36 @@ public class LuceneFunctionReadPathDUnitTest extends CacheTestCase {
   }
 
   public void testEnd2EndFunctionExecution() {
-    SerializableRunnable createPartitionRegion = new SerializableRunnable("createRegion") {
+    SerializableCallable createPartitionRegion = new SerializableCallable("createRegion") {
       private static final long serialVersionUID = 1L;
 
-      public void run() {
+      public Object call() throws Exception {
         final Cache cache = getCache();
         assertNotNull(cache);
         RegionFactory<Object, Object> regionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
-        regionFactory.create(REGION_NAME);
+        Region<Object, Object> region = regionFactory.create(REGION_NAME);
+        
 
         LuceneService service = LuceneServiceProvider.get(cache);
-        service.createIndex(INDEX_NAME, REGION_NAME);
-
-        IndexRepository mockRepo = mock(IndexRepository.class);
-        Collection<IndexRepository> repos = new ArrayList<IndexRepository>();
-        repos.add(mockRepo);
-
-        RepositoryManager mockManager = mock(RepositoryManager.class);
-        // TODO avoid using repository manager mock. The manager choice depends on the region type
-        LuceneFunction.setRepositoryManager(mockManager);
+        InternalLuceneIndex index = (InternalLuceneIndex) service.createIndex(INDEX_NAME, REGION_NAME, "text");
+        
+        
+        region.put(1, new TestObject("hello world"));
+        region.put(2, new TestObject("goodbye world"));
+        
+        //TODO - the async event queue hasn't been hooked up, so we'll fake out
+        //writing the entry to the repository.
         try {
-          Mockito.doReturn(repos).when(mockManager).getRepositories(any(Region.class));
-        } catch (BucketNotFoundException e) {
-          fail("", e);
-        }
-
-        try {
-          Mockito.doAnswer(new Answer<Object>() {
-            public Object answer(InvocationOnMock invocation) {
-              Object[] args = invocation.getArguments();
-              IndexResultCollector collector = (IndexResultCollector) args[2];
-              collector.collect(cache.getDistributedSystem().getDistributedMember().getProcessId(), .1f);
-              return null;
-            }
-          }).when(mockRepo).query(any(Query.class), Mockito.anyInt(), any(IndexResultCollector.class));
-        } catch (IOException e) {
-          fail("", e);
+        IndexRepository repository1 = index.getRepositoryManager().getRepository(region, 1, null);
+        repository1.create(1, new TestObject("hello world"));
+        repository1.commit();
+        IndexRepository repository2 = index.getRepositoryManager().getRepository(region, 2, null);
+        repository2.create(2, new TestObject("hello world"));
+        repository2.commit();
+        } catch(BucketNotFoundException e) {
+          //thats ok, one of the data stores does not host these buckets.
         }
+        return null;
       }
     };
 
@@ -115,9 +98,9 @@ public class LuceneFunctionReadPathDUnitTest extends CacheTestCase {
 
         LuceneService service = LuceneServiceProvider.get(cache);
         LuceneIndex index = service.getIndex(INDEX_NAME, REGION_NAME);
-        LuceneQueryProvider provider = new StringQueryProvider(index, "text:search");
+        LuceneQueryProvider provider = new StringQueryProvider("text:world");
 
-        LuceneFunctionContext<TopEntriesCollector> context = new LuceneFunctionContext<>(provider,
+        LuceneFunctionContext<TopEntriesCollector> context = new LuceneFunctionContext<>(provider, index.getName(),
             new TopEntriesCollectorManager());
         TopEntriesFunctionCollector collector = new TopEntriesFunctionCollector();
 
@@ -135,4 +118,15 @@ public class LuceneFunctionReadPathDUnitTest extends CacheTestCase {
 
     server1.invoke(executeSearch);
   }
+  
+  private static class TestObject implements Serializable {
+    private String text;
+
+    public TestObject(String text) {
+      this.text = text;
+    }
+    
+    
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/TopEntriesFunctionCollectorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/TopEntriesFunctionCollectorJUnitTest.java b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/TopEntriesFunctionCollectorJUnitTest.java
index a66f2fc..5f7dc3d 100644
--- a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/TopEntriesFunctionCollectorJUnitTest.java
+++ b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/TopEntriesFunctionCollectorJUnitTest.java
@@ -184,7 +184,7 @@ public class TopEntriesFunctionCollectorJUnitTest {
 
   @Test
   public void mergeShardAndLimitResults() throws Exception {
-    LuceneFunctionContext<TopEntriesCollector> context = new LuceneFunctionContext<>(null, null, 3);
+    LuceneFunctionContext<TopEntriesCollector> context = new LuceneFunctionContext<>(null, null, null, 3);
     
     TopEntriesFunctionCollector collector = new TopEntriesFunctionCollector(context);
     collector.addResult(null, result1);
@@ -226,7 +226,7 @@ public class TopEntriesFunctionCollectorJUnitTest {
           }
         }));
 
-    LuceneFunctionContext<TopEntriesCollector> context = new LuceneFunctionContext<>(null, mockManager);
+    LuceneFunctionContext<TopEntriesCollector> context = new LuceneFunctionContext<>(null, null, mockManager);
     TopEntriesFunctionCollector collector = new TopEntriesFunctionCollector(context);
     collector.addResult(null, result1);
     collector.addResult(null, result2);
@@ -255,7 +255,7 @@ public class TopEntriesFunctionCollectorJUnitTest {
     TopEntriesCollectorManager mockManager = mock(TopEntriesCollectorManager.class);
     Mockito.doThrow(new IOException()).when(mockManager).reduce(any(Collection.class));
 
-    LuceneFunctionContext<TopEntriesCollector> context = new LuceneFunctionContext<>(null, mockManager);
+    LuceneFunctionContext<TopEntriesCollector> context = new LuceneFunctionContext<>(null, null, mockManager);
     TopEntriesFunctionCollector collector = new TopEntriesFunctionCollector(context);
     collector.endResults();
     collector.getResult();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8fb4ad7a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/repository/IndexRepositoryImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/repository/IndexRepositoryImplJUnitTest.java b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/repository/IndexRepositoryImplJUnitTest.java
index 3a25c97..ede267c 100644
--- a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/repository/IndexRepositoryImplJUnitTest.java
+++ b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/repository/IndexRepositoryImplJUnitTest.java
@@ -65,6 +65,12 @@ public class IndexRepositoryImplJUnitTest {
     repo.commit();
     
     checkQuery("Cream", "s", "key2", "key4");
+    checkQuery("NotARealWord", "s");
+  }
+  
+  @Test
+  public void testEmptyRepo() throws IOException, ParseException {
+    checkQuery("NotARealWord", "s");
   }
   
   @Test


Mime
View raw message