opensearch-project / terraform-provider-opensearch

https://registry.terraform.io/providers/opensearch-project/opensearch
Apache License 2.0
74 stars 58 forks source link

[BUG] Unable to configure opensearch index with index_knn setting = true #176

Closed FireAndIceFrog closed 6 months ago

FireAndIceFrog commented 6 months ago

What is the bug?

Trying to set up an opensearch index with the terraform throws a 400 request:

Error: elastic: Error 400 (Bad Request): unknown setting [index.knn] please check that any required plugins are installed, or check the breaking changes documentation for removed settings [type=illegal_argument_exception]

How can one reproduce the bug?

Using the default docker compose, with the environment flag

environment:
    - OPENSEARCH_PLUGINS=knn

and terraform file

terraform {
  required_providers {
    opensearch = {
      source = "opensearch-project/opensearch"
      version = "2.2.1"
    }
  }
}

provider "opensearch" {
  url = "http://127.0.0.1:9200"
  username          = "admin"
  password          = "This1s@verylongPAss"
  # Must be disabled for basic auth
  sign_aws_requests = false
}

resource "opensearch_index" "opensearch-index" {
  name               = "hackathon-index"
  number_of_shards   = "1"
  number_of_replicas = "1"
  rollover_alias = "hackathon-index"
  index_knn = true

  mappings           = <<EOF
{
  "properties": {
    "name": {"type": "text"},
    "id": {"type": "integer"},
    "description": {"type": "text"}
  }
}
EOF
}

Throws the error

What is the expected behavior?

This should just be created

What is your host/environment?

Opensearch 2.0.0 terraform 2.2.1 windows 11

image

Please note: This exact index can be created manually via the dashboard

FireAndIceFrog commented 6 months ago

Turns out I was an instance of elastic search on the same port. For anyone wondering whats wrong, hit the endpoint and check to see it needs auth!