private InternalLuceneIndex getLuceneIndex(final Cache cache, final Region region,
      final LuceneFunctionContext<IndexResultCollector> searchContext) {
    LuceneService service = LuceneServiceProvider.get(cache);
    InternalLuceneIndex index = null;
    try {
      index = (InternalLuceneIndex) service.getIndex(searchContext.getIndexName(),
          region.getFullPath());
      if (index == null) {
        while (service instanceof LuceneServiceImpl && (((LuceneServiceImpl) service)
            .getDefinedIndex(searchContext.getIndexName(), region.getFullPath()) != null)) {
          try {
            Thread.sleep(10);
          } catch (InterruptedException e) {
            return null;
          }
          cache.getCancelCriterion().checkCancelInProgress(null);
        }
        index = (InternalLuceneIndex) service.getIndex(searchContext.getIndexName(),
            region.getFullPath());
      }
    } catch (CacheClosedException e) {
      throw new InternalFunctionInvocationTargetException(
          "Cache is closed when attempting to retrieve index:" + region.getFullPath(), e);
    }

    return index;
  }
{@link LuceneQueryFunction} coordinates text search on a member. It receives text search query
from the coordinator and arguments like region and buckets. It invokes search on the local index
and provides a result collector. The locally collected results are sent to the search
coordinator.
geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java