diff --git a/flint-spark-integration/src/main/scala/org/opensearch/flint/spark/FlintSpark.scala b/flint-spark-integration/src/main/scala/org/opensearch/flint/spark/FlintSpark.scala index 6e62c34c3..4a4885ecb 100644 --- a/flint-spark-integration/src/main/scala/org/opensearch/flint/spark/FlintSpark.scala +++ b/flint-spark-integration/src/main/scala/org/opensearch/flint/spark/FlintSpark.scala @@ -86,12 +86,10 @@ class FlintSpark(val spark: SparkSession) { throw new IllegalStateException(s"Flint index $indexName already exists") } } else { - flintClient.createIndex(indexName, index.metadata()) + val metadata = index.metadata() + index.options.indexSettings().foreach(metadata.setIndexSettings) + flintClient.createIndex(indexName, metadata) } - - val metadata = index.metadata() - index.options.indexSettings().foreach(metadata.setIndexSettings) - flintClient.createIndex(indexName, metadata) } /** diff --git a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkSkippingIndexITSuite.scala b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkSkippingIndexITSuite.scala index bc7c6ab4a..0740955c7 100644 --- a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkSkippingIndexITSuite.scala +++ b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkSkippingIndexITSuite.scala @@ -133,11 +133,12 @@ class FlintSparkSkippingIndexITSuite extends FlintSparkSuite { | } |""".stripMargin) + // Load index options from index mapping (verify OS index setting in SQL IT) index.get.options.autoRefresh() shouldBe true index.get.options.refreshInterval() shouldBe Some("1 Minute") index.get.options.checkpointLocation() shouldBe Some("s3a://test/") index.get.options.indexSettings() shouldBe - "{\"number_of_shards\": 3,\"number_of_replicas\": 2}" + Some("{\"number_of_shards\": 3,\"number_of_replicas\": 2}") } test("should not have ID column in index data") { diff --git a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkSkippingIndexSqlITSuite.scala b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkSkippingIndexSqlITSuite.scala index 3a03b35eb..21acef471 100644 --- a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkSkippingIndexSqlITSuite.scala +++ b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkSkippingIndexSqlITSuite.scala @@ -90,7 +90,7 @@ class FlintSparkSkippingIndexSqlITSuite extends FlintSparkSuite { | ) |""".stripMargin) - // Check if the index settings is set to OS index + // Check if the index setting option is set to OS index setting val flintClient = new FlintOpenSearchClient(new FlintOptions(openSearchOptions.asJava)) implicit val formats: Formats = Serialization.formats(NoTypeHints)