use of org.hibernate.search.util.common.SearchException in project infinispan by infinispan.
the class MassIndexerProgressNotifier method notifyIndexingCompletedSuccessfully.
void notifyIndexingCompletedSuccessfully() {
monitor.indexingCompleted();
SearchException entityIndexingException = createEntityIndexingExceptionOrNull();
if (entityIndexingException != null) {
throw entityIndexingException;
}
}
use of org.hibernate.search.util.common.SearchException in project hibernate-search by hibernate.
the class SearchTimeoutIT method failAfter.
@Test
public void failAfter() {
try (SearchSession session = mapping.createSession()) {
SearchQuery<EntityReference> query = session.search(IndexedEntity.class).selectEntityReference().where(f -> f.matchAll()).failAfter(5L, TimeUnit.SECONDS).toQuery();
SearchException timeoutException = new SearchException("Timed out");
backendMock.expectSearchReferences(Collections.singletonList(INDEX_NAME), // timeout is supposed to be set on the backend
b -> b.failAfter(5L, TimeUnit.SECONDS), StubSearchWorkBehavior.failing(() -> timeoutException));
// Just check that the exception is propagated
assertThatThrownBy(() -> query.fetchAll()).isSameAs(timeoutException);
}
}
use of org.hibernate.search.util.common.SearchException in project hibernate-search by hibernate.
the class SpatialIndexingTest method testNonGeoDistanceSortOnNonSpatialField.
@Test
@TestForIssue(jiraKey = "HSEARCH-1708")
public void testNonGeoDistanceSortOnNonSpatialField() throws Exception {
double centerLatitude = 24.0d;
double centerLongitude = 32.0d;
final QueryBuilder builder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(NonGeoPOI.class).get();
try {
builder.sort().byDistance().onField("name").fromLatitude(centerLatitude).andLongitude(centerLongitude).createSort();
fail("Sorting on a field that it is not a coordinate should fail");
} catch (SearchException e) {
assertThat(e).hasMessageContaining("Cannot use 'sort:distance' on field 'name'");
}
}
use of org.hibernate.search.util.common.SearchException in project hibernate-search by hibernate.
the class SpatialIndexingTest method testNonGeoDistanceSortOnMissingField.
@Test
@TestForIssue(jiraKey = "HSEARCH-1708")
public void testNonGeoDistanceSortOnMissingField() throws Exception {
double centerLatitude = 24.0d;
double centerLongitude = 32.0d;
final QueryBuilder builder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(NonGeoPOI.class).get();
try {
builder.sort().byDistance().onField("location").fromLatitude(centerLatitude).andLongitude(centerLongitude).createSort();
fail("Sorting on a field not indexed should fail");
} catch (SearchException e) {
assertThat(e).hasMessageContaining("Unknown field 'location'");
}
}
use of org.hibernate.search.util.common.SearchException in project hibernate-search by hibernate.
the class MassIndexingMonitorIT method simple.
@Test
public void simple() {
SessionFactory sessionFactory = setup(null);
with(sessionFactory).runNoTransaction(session -> {
SearchSession searchSession = Search.session(session);
MassIndexer indexer = searchSession.massIndexer();
CompletableFuture<?> indexingFuture = new CompletableFuture<>();
indexingFuture.completeExceptionally(new SimulatedFailure("Indexing error"));
// add operations on indexes can follow any random order,
// since they are executed by different threads
backendMock.expectWorks(Book.INDEX, DocumentCommitStrategy.NONE, DocumentRefreshStrategy.NONE).add("1", b -> b.field("title", TITLE_1).field("author", AUTHOR_1)).add("3", b -> b.field("title", TITLE_3).field("author", AUTHOR_3)).createAndExecuteFollowingWorks(indexingFuture).add("2", b -> b.field("title", TITLE_2).field("author", AUTHOR_2));
// purgeAtStart and mergeSegmentsAfterPurge are enabled by default,
// so we expect 1 purge, 1 mergeSegments and 1 flush calls in this order:
backendMock.expectIndexScaleWorks(Book.INDEX, session.getTenantIdentifier()).purge().mergeSegments().flush().refresh();
try {
indexer.monitor(new StaticCountersMonitor()).startAndWait();
} catch (SearchException ignored) {
// Expected, but not relevant to this test
} catch (InterruptedException e) {
fail("Unexpected InterruptedException: " + e.getMessage());
}
});
backendMock.verifyExpectationsMet();
assertThat(staticCounters.get(StaticCountersMonitor.LOADED)).isEqualTo(3);
assertThat(staticCounters.get(StaticCountersMonitor.BUILT)).isEqualTo(3);
assertThat(staticCounters.get(StaticCountersMonitor.ADDED)).isEqualTo(2);
assertThat(staticCounters.get(StaticCountersMonitor.TOTAL)).isEqualTo(3);
assertThat(staticCounters.get(StaticCountersMonitor.INDEXING_COMPLETED)).isEqualTo(1);
}
Aggregations