Skip to content

Commit

Permalink
Align Hibernate Search configuration defaults on Hibernate Search 7
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Nov 24, 2023
1 parent 3a1e400 commit ab4459f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.quarkus.hibernate.search.orm.elasticsearch.test.search.shard_failure;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import java.util.List;

Expand Down Expand Up @@ -39,12 +39,13 @@ public void testShardFailureIgnored() {
session.toEntityManager().persist(new MyEntity2("42"));
});
QuarkusTransaction.joiningExisting().run(() -> {
assertThat(session.search(List.of(MyEntity1.class, MyEntity2.class))
assertThatThrownBy(() -> session.search(List.of(MyEntity1.class, MyEntity2.class))
.where(f -> f.wildcard().field("text").matching("4*"))
.fetchHits(20))
// MyEntity2 fails because "text" is an integer field there
// We expect that index (shard) to be ignored
.hasSize(1);
// We expect an exception
.hasMessageContaining("Elasticsearch request failed",
"\"type\": \"query_shard_exception\"");
});
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.quarkus.hibernate.search.orm.elasticsearch.test.search.shard_failure;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;

Expand All @@ -14,7 +14,7 @@
import io.quarkus.narayana.jta.QuarkusTransaction;
import io.quarkus.test.QuarkusUnitTest;

public class ShardFailureIgnoreFalseTest {
public class ShardFailureIgnoreTrueTest {

@RegisterExtension
static QuarkusUnitTest runner = new QuarkusUnitTest()
Expand All @@ -24,8 +24,8 @@ public class ShardFailureIgnoreFalseTest {
.addClass(MyEntity2.class)
.addAsResource("hsearch-4915/index2.json"))
.withConfigurationResource("application.properties")
// Request that shard failures cause an exception instead of being ignored
.overrideConfigKey("quarkus.hibernate-search-orm.elasticsearch.query.shard-failure.ignore", "false")
// Request that shard failures be ignored
.overrideConfigKey("quarkus.hibernate-search-orm.elasticsearch.query.shard-failure.ignore", "true")
// Override the type of the keyword field to integer, to create an error in one shard only.
.overrideConfigKey(
"quarkus.hibernate-search-orm.elasticsearch.indexes.\"MyEntity2\".schema-management.mapping-file",
Expand All @@ -41,13 +41,12 @@ public void testShardFailureIgnored() {
session.toEntityManager().persist(new MyEntity2("42"));
});
QuarkusTransaction.joiningExisting().run(() -> {
assertThatThrownBy(() -> session.search(List.of(MyEntity1.class, MyEntity2.class))
assertThat(session.search(List.of(MyEntity1.class, MyEntity2.class))
.where(f -> f.wildcard().field("text").matching("4*"))
.fetchHits(20))
// MyEntity2 fails because "text" is an integer field there
// We expect an exception
.hasMessageContaining("Elasticsearch request failed",
"\"type\": \"query_shard_exception\"");
// We expect that index (shard) to be ignored
.hasSize(1);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,8 @@ interface ElasticsearchQueryShardFailureConfig {
/**
* Whether partial shard failures are ignored (`true`)
* or lead to Hibernate Search throwing an exception (`false`).
* <p>
* Will default to `false` in Hibernate Search 7.
*/
@WithDefault("true")
@WithDefault("false")
boolean ignore();
}

Expand Down

0 comments on commit ab4459f

Please sign in to comment.