if (luceneService.getIndex(queryInfo.getIndexName(), queryInfo.getRegionPath()) == null) { throw new Exception("Index " + queryInfo.getIndexName() + " not found on region " + queryInfo.getRegionPath()); final LuceneQuery<K, V> query = luceneService.createLuceneQueryFactory() .setLimit(queryInfo.getLimit()).create(queryInfo.getIndexName(), queryInfo.getRegionPath(), queryInfo.getQueryString(), queryInfo.getDefaultField());
public static void createIndex(Cache cache, String... fieldNames) { final LuceneIndexFactory indexFactory = LuceneServiceProvider.get(cache).createIndexFactory(); indexFactory.setFields(fieldNames).create(INDEX_NAME, REGION_NAME); }
public static void verifyIndexFinishFlushing(Cache cache, String indexName, String regionName) throws InterruptedException { LuceneService luceneService = LuceneServiceProvider.get(cache); LuceneIndex index = luceneService.getIndex(indexName, regionName); boolean flushed = luceneService.waitUntilFlushed(indexName, regionName, 60000, TimeUnit.MILLISECONDS); assertTrue(flushed); }
when(mockLuceneService.createIndexFactory()) .thenAnswer(invocation -> mockLuceneIndexFactory(luceneIndexes)); when(mockLuceneService.createLuceneQueryFactory()) .thenAnswer(invocation -> mockLuceneQueryFactory()); }).when(mockLuceneService).destroyIndex(anyString(), anyString()); }).when(mockLuceneService).destroyIndexes(anyString()); when(mockLuceneService.getAllIndexes()).thenAnswer(invocation -> Collections.unmodifiableCollection(luceneIndexes.values())); when(mockLuceneService.getCache()).thenReturn(mockCache); when(mockLuceneService.getIndex(anyString(), anyString())).thenAnswer(invocation -> { when(mockLuceneService.waitUntilFlushed(anyString(), anyString(), anyLong(), any(TimeUnit.class))) .thenReturn(true));
public LuceneIndexMetrics listIndexMetrics(String regionPath, String indexName) { LuceneIndex index = this.service.getIndex(indexName, regionPath); return index == null ? null : getIndexMetrics(index); }
LuceneIndexFactory indexFactory = luceneService.createIndexFactory(); indexFactory.create(indexName, regionPath); return luceneService.getIndex(indexName, regionPath);
/** * Creates an instance of the {@link LuceneQueryFactory} to create and execute {@link LuceneQuery Lucene queries}. * * @return an instance of the {@link LuceneQueryFactory} to create and execute {@link LuceneQuery Lucene queries}. * @see org.apache.geode.cache.lucene.LuceneQueryFactory * @see #getLuceneService() */ public LuceneQueryFactory createLuceneQueryFactory() { return resolveLuceneService().createLuceneQueryFactory(); }
Exception destroyIndexesException = null; try { service.destroyIndexes(regionPath); destroyIndexesResult = new CliFunctionResult(memberId, getXmlEntity(indexName, regionPath)); result = new CliFunctionResult(memberId); } else { service.destroyIndex(indexName, regionPath); result = new CliFunctionResult(memberId, getXmlEntity(indexName, regionPath));
/** * @inheritDoc */ @Override @SuppressWarnings("all") public void destroy() throws Exception { LuceneIndex luceneIndex = getObject(); if (isLuceneIndexDestroyable(luceneIndex)) { resolveLuceneService().destroyIndex(luceneIndex.getName(), luceneIndex.getRegionPath()); } }
public static void putEntries(LuceneService luceneService, Map<String, TrainStop> region) throws InterruptedException { region.put("Elmonica/SW 170th Ave", new TrainStop("Elmonica/SW 170th Ave", -122.85146341202486, 45.509962691078009)); region.put("Willow Creek/SW 185th Ave TC", new TrainStop("Willow Creek/SW 185th Ave TC", -122.87021024485213, 45.517251954169652)); region.put("Merlo Rd/SW 158th Ave", new TrainStop("Merlo Rd/SW 158th Ave", -122.84216239020598, 45.505240564251949)); // Lucene indexing happens asynchronously, so wait for // the entries to be in the lucene index. luceneService.waitUntilFlushed("simpleIndex", "example-region", 1, TimeUnit.MINUTES); } }
public LuceneIndexMetrics[] listIndexMetrics() { Collection<LuceneIndex> indexes = this.service.getAllIndexes(); LuceneIndexMetrics[] indexMetrics = new LuceneIndexMetrics[indexes.size()]; int i = 0; for (LuceneIndex index : this.service.getAllIndexes()) { indexMetrics[i++] = getIndexMetrics(index); } return indexMetrics; }
public static void verifyInternalRegions(LuceneService luceneService, Cache cache, Consumer<LocalRegion> verify) { // Get index LuceneIndexForPartitionedRegion index = (LuceneIndexForPartitionedRegion) luceneService.getIndex(INDEX_NAME, REGION_NAME); LocalRegion fileRegion = (LocalRegion) cache.getRegion(index.createFileRegionName()); verify.accept(fileRegion); }
LuceneIndexFactory indexFactory = luceneService.createIndexFactory(); indexFactory.create(indexName, regionPath); return luceneService.getIndex(indexName, regionPath);
/** * Creates an instance of the {@link LuceneQueryFactory} to create and execute {@link LuceneQuery Lucene queries}. * * @return an instance of the {@link LuceneQueryFactory} to create and execute {@link LuceneQuery Lucene queries}. * @see org.apache.geode.cache.lucene.LuceneQueryFactory * @see #getLuceneService() */ public LuceneQueryFactory createLuceneQueryFactory() { return resolveLuceneService().createLuceneQueryFactory(); }
/** * @inheritDoc */ @Override @SuppressWarnings("all") public void destroy() throws Exception { LuceneIndex luceneIndex = getObject(); if (isLuceneIndexDestroyable(luceneIndex)) { resolveLuceneService().destroyIndex(luceneIndex.getName(), luceneIndex.getRegionPath()); } }
public LuceneIndexMetrics[] listIndexMetrics(String regionPath) { if (!regionPath.startsWith(Region.SEPARATOR)) { regionPath = Region.SEPARATOR + regionPath; } List<LuceneIndexMetrics> indexMetrics = new ArrayList(); for (LuceneIndex index : this.service.getAllIndexes()) { if (index.getRegionPath().equals(regionPath)) { indexMetrics.add(getIndexMetrics(index)); } } return indexMetrics.toArray(new LuceneIndexMetrics[indexMetrics.size()]); }
LuceneService service = LuceneServiceProvider.get(ctx.getDataSet().getCache()); InternalLuceneIndex index = (InternalLuceneIndex) service.getIndex(indexName, region.getFullPath()); if (index == null) { throw new IllegalStateException(
public static void findNearbyTrainStops(LuceneService luceneService) throws InterruptedException, LuceneQueryException { LuceneQuery<Integer, TrainStop> query = luceneService.createLuceneQueryFactory().create("simpleIndex", "example-region", index -> SpatialHelper.findWithin(-122.8515139, 45.5099231, 0.25)); Collection<TrainStop> results = query.findValues(); System.out.println("Found stops: " + results); }
(LuceneIndexFactoryImpl) service.createIndexFactory(); if (analyzerName == null || analyzerName.length == 0) { for (String field : fields) {
@Override public void execute(FunctionContext<Object> context) { RegionFunctionContext ctx = (RegionFunctionContext) context; ResultSender<Boolean> resultSender = ctx.getResultSender(); Region region = ctx.getDataSet(); Cache cache = region.getCache(); String indexName = (String) ctx.getArguments(); if (indexName == null) { throw new IllegalArgumentException("Missing index name"); } LuceneService luceneService = LuceneServiceProvider.get(cache); LuceneIndex luceneIndex = luceneService.getIndex(indexName, region.getFullPath()); if (luceneIndex == null) { resultSender.lastResult(false); } else { resultSender.lastResult(luceneIndex.isIndexingInProgress()); } }