diff --git a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/IndexManagementPlugin.kt b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/IndexManagementPlugin.kt index 591ab039f..09d6473fc 100644 --- a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/IndexManagementPlugin.kt +++ b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/IndexManagementPlugin.kt @@ -75,6 +75,7 @@ internal class IndexManagementPlugin : JobSchedulerExtension, ActionPlugin, Plug const val PLUGIN_NAME = "opendistro-im" const val OPEN_DISTRO_BASE_URI = "/_opendistro" const val ISM_BASE_URI = "$OPEN_DISTRO_BASE_URI/_ism" + const val ANALYZER_BASE_URI = "$OPEN_DISTRO_BASE_URI/_analyzer" const val POLICY_BASE_URI = "$ISM_BASE_URI/policies" const val INDEX_MANAGEMENT_INDEX = ".opendistro-ism-config" const val INDEX_MANAGEMENT_JOB_TYPE = "opendistro-index-management" diff --git a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RestRefreshSynonymAnalyzerAction.kt b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RestRefreshSynonymAnalyzerAction.kt index 031bf7233..a72754f53 100644 --- a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RestRefreshSynonymAnalyzerAction.kt +++ b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RestRefreshSynonymAnalyzerAction.kt @@ -15,6 +15,7 @@ package com.amazon.opendistroforelasticsearch.indexmanagement.refreshanalyzer +import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementPlugin.Companion.ANALYZER_BASE_URI import org.elasticsearch.client.node.NodeClient import org.elasticsearch.common.Strings import org.elasticsearch.rest.BaseRestHandler @@ -54,6 +55,6 @@ class RestRefreshSynonymAnalyzerAction : BaseRestHandler() { } companion object { - const val REFRESH_SYNONYM_ANALYZER_URI = "/{index}/_refresh_synonym_analyzer" + const val REFRESH_SYNONYM_ANALYZER_URI = "$ANALYZER_BASE_URI/refresh_synonym_analyzer/{index}" } } diff --git a/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSynonymAnalyzerActionIT.kt b/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSynonymAnalyzerActionIT.kt index be164b150..6e18964e1 100644 --- a/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSynonymAnalyzerActionIT.kt +++ b/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSynonymAnalyzerActionIT.kt @@ -15,6 +15,7 @@ package com.amazon.opendistroforelasticsearch.indexmanagement.refreshanalyzer +import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementPlugin import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementRestTestCase import org.elasticsearch.client.Request import org.elasticsearch.common.io.Streams @@ -202,7 +203,8 @@ class RefreshSynonymAnalyzerActionIT : IndexManagementRestTestCase() { } fun refreshAnalyzer(indexName: String) { - val request = Request("POST", "/$indexName/_refresh_synonym_analyzer") + val request = Request("POST", + "${IndexManagementPlugin.ANALYZER_BASE_URI}/refresh_synonym_analyzer/$indexName") client().performRequest(request) } diff --git a/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RestRefreshSynonymAnalyzerActionIT.kt b/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RestRefreshSynonymAnalyzerActionIT.kt index 779b540df..e3243d89d 100644 --- a/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RestRefreshSynonymAnalyzerActionIT.kt +++ b/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RestRefreshSynonymAnalyzerActionIT.kt @@ -15,6 +15,7 @@ package com.amazon.opendistroforelasticsearch.indexmanagement.refreshanalyzer +import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementPlugin.Companion.ANALYZER_BASE_URI import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementRestTestCase import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.makeRequest import org.elasticsearch.client.ResponseException @@ -26,7 +27,7 @@ class RestRefreshSynonymAnalyzerActionIT : IndexManagementRestTestCase() { fun `test missing indices`() { try { - client().makeRequest(POST.toString(), "//_refresh_synonym_analyzer") + client().makeRequest(POST.toString(), "$ANALYZER_BASE_URI/refresh_synonym_analyzer") fail("Expected a failure") } catch (e: ResponseException) { assertEquals("Unexpected RestStatus", RestStatus.BAD_REQUEST, e.response.restStatus()) @@ -34,10 +35,10 @@ class RestRefreshSynonymAnalyzerActionIT : IndexManagementRestTestCase() { val expectedErrorMessage = mapOf( "error" to mapOf( "root_cause" to listOf>( - mapOf("type" to "illegal_argument_exception", "reason" to "Missing indices") + mapOf("type" to "parse_exception", "reason" to "request body is required") ), - "type" to "illegal_argument_exception", - "reason" to "Missing indices" + "type" to "parse_exception", + "reason" to "request body is required" ), "status" to 400 ) @@ -52,7 +53,7 @@ class RestRefreshSynonymAnalyzerActionIT : IndexManagementRestTestCase() { closeIndex(indexName) try { - client().makeRequest(POST.toString(), "/$indexName/_refresh_synonym_analyzer") + client().makeRequest(POST.toString(), "$ANALYZER_BASE_URI/refresh_synonym_analyzer/$indexName") fail("Expected a failure") } catch (e: ResponseException) { val response = e.response.asMap()