Search in sources :

Example 6 with InvalidIndexTemplateException

use of org.opensearch.indices.InvalidIndexTemplateException in project OpenSearch by opensearch-project.

the class SearchPhaseExecutionExceptionTests method testPhaseFailureWithSearchShardFailure.

public void testPhaseFailureWithSearchShardFailure() {
    final ShardSearchFailure[] shardSearchFailures = new ShardSearchFailure[randomIntBetween(1, 5)];
    for (int i = 0; i < shardSearchFailures.length; i++) {
        Exception cause = randomFrom(new ParsingException(1, 2, "foobar", null), new InvalidIndexTemplateException("foo", "bar"));
        shardSearchFailures[i] = new ShardSearchFailure(cause, new SearchShardTarget("node_" + i, new ShardId("test", "_na_", i), null, OriginalIndices.NONE));
    }
    final String phase = randomFrom("fetch", "search", "other");
    SearchPhaseExecutionException actual = new SearchPhaseExecutionException(phase, "unexpected failures", new OpenSearchRejectedExecutionException("OpenSearch rejected execution of fetch phase"), shardSearchFailures);
    assertEquals(actual.status(), RestStatus.BAD_REQUEST);
}
Also used : ShardId(org.opensearch.index.shard.ShardId) TimestampParsingException(org.opensearch.action.TimestampParsingException) ParsingException(org.opensearch.common.ParsingException) InvalidIndexTemplateException(org.opensearch.indices.InvalidIndexTemplateException) SearchShardTarget(org.opensearch.search.SearchShardTarget) OpenSearchRejectedExecutionException(org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException) OpenSearchRejectedExecutionException(org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException) IndexShardClosedException(org.opensearch.index.shard.IndexShardClosedException) IOException(java.io.IOException) OpenSearchException(org.opensearch.OpenSearchException) TimestampParsingException(org.opensearch.action.TimestampParsingException) InvalidIndexTemplateException(org.opensearch.indices.InvalidIndexTemplateException) ParsingException(org.opensearch.common.ParsingException)

Example 7 with InvalidIndexTemplateException

use of org.opensearch.indices.InvalidIndexTemplateException in project OpenSearch by opensearch-project.

the class HiddenIndexIT method testGlobalTemplateCannotMakeIndexHidden.

public void testGlobalTemplateCannotMakeIndexHidden() {
    InvalidIndexTemplateException invalidIndexTemplateException = expectThrows(InvalidIndexTemplateException.class, () -> client().admin().indices().preparePutTemplate("a_global_template").setPatterns(Collections.singletonList("*")).setSettings(Settings.builder().put("index.hidden", randomBoolean()).build()).get());
    assertThat(invalidIndexTemplateException.getMessage(), containsString("global templates may not specify the setting index.hidden"));
}
Also used : InvalidIndexTemplateException(org.opensearch.indices.InvalidIndexTemplateException)

Aggregations

InvalidIndexTemplateException (org.opensearch.indices.InvalidIndexTemplateException)7 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)3 Alias (org.opensearch.action.admin.indices.alias.Alias)3 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Version (org.opensearch.Version)2 ActionListener (org.opensearch.action.ActionListener)2 AcknowledgedResponse (org.opensearch.action.support.master.AcknowledgedResponse)2 ClusterState (org.opensearch.cluster.ClusterState)2 ClusterService (org.opensearch.cluster.service.ClusterService)2 Strings (org.opensearch.common.Strings)2 ValidationException (org.opensearch.common.ValidationException)2 BytesReference (org.opensearch.common.bytes.BytesReference)2