gedi.solutions.geode.lucene.GeodeLuceneSearch Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gedi-geode-extensions-core Show documentation
Show all versions of gedi-geode-extensions-core Show documentation
GemFire Enterprise Data Integration - common development extensions powered by Apache Geode
The newest version!
package gedi.solutions.geode.lucene;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
import java.util.stream.Collectors;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.execute.FunctionService;
import org.apache.geode.cache.lucene.LuceneQuery;
import org.apache.geode.cache.lucene.LuceneQueryException;
import org.apache.geode.cache.lucene.LuceneResultStruct;
import org.apache.geode.cache.lucene.LuceneService;
import org.apache.geode.cache.lucene.LuceneServiceProvider;
import gedi.solutions.geode.client.GeodeClient;
import gedi.solutions.geode.io.GemFireIO;
import gedi.solutions.geode.io.Querier;
import gedi.solutions.geode.lucene.function.SimpleLuceneSearchFunction;
import nyla.solutions.core.data.MapEntry;
import nyla.solutions.core.exception.SystemException;
import nyla.solutions.core.util.BeanComparator;
import nyla.solutions.core.util.Organizer;
/**
* Implement for searching Lucene
* @author Gregory Green
*
*/
public class GeodeLuceneSearch
{
private final LuceneService luceneService;
/**
*
* @param gemFireCache the cache
*/
public GeodeLuceneSearch(GemFireCache gemFireCache)
{
this(LuceneServiceProvider.get(gemFireCache));
}//------------------------------------------------
/**
*
* @param luceneService the luceneService
*/
public GeodeLuceneSearch(LuceneService luceneService)
{
this.luceneService = luceneService;
}//------------------------------------------------
public Collection saveSearchResultsWithPageKeys(TextPageCriteria criteria, Region> pageKeysRegion)
{
if(criteria == null)
return null;
if(criteria.getQuery() == null || criteria.getQuery().length() == 0)
return null;
if(criteria.getIndexName() == null || criteria.getIndexName().length() == 0)
throw new IllegalArgumentException("Default criteria's indexName is required");
if(criteria.getId() == null || criteria.getId().length() == 0)
throw new IllegalArgumentException("Default criteria's id is required");
if(criteria.getDefaultField() == null || criteria.getDefaultField().length() == 0)
throw new IllegalArgumentException("Default criteria's defaultField is required");
try
{
LuceneQuery