Skip to content

Error: error getting search index information: json: cannot unmarshal array into Go struct field IndexMapping.mappings.fields of type mongodbatlas.IndexField #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stefanosala opened this issue Aug 30, 2021 · 4 comments · Fixed by #548
Labels

Comments

@stefanosala
Copy link
Contributor

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v1.0.4
on darwin_amd64
+ provider registry.terraform.io/cloudamqp/cloudamqp v1.9.2
+ provider registry.terraform.io/hashicorp/aws v3.24.1
+ provider registry.terraform.io/hashicorp/google v3.81.0
+ provider registry.terraform.io/hashicorp/null v3.0.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/hashicorp/template v2.2.0
+ provider registry.terraform.io/heroku/heroku v4.1.1
+ provider registry.terraform.io/jianyuan/sentry v0.6.0
+ provider registry.terraform.io/mongodb/mongodbatlas v1.0.0
+ provider registry.terraform.io/redislabs/rediscloud v0.2.1

Terraform configuration

resource "mongodbatlas_search_index" "skus" {
  project_id      = mongodbatlas_project.main.id
  cluster_name    = mongodbatlas_cluster.main.name
  analyzer        = "lucene.standard"
  collection_name = "skus"
  database        = var.prefix
  mappings_fields = file("./templates/mongodb/search-skus.json")
  name            = "skus.search"
}

# search-skus.json
{
  "account": {
    "type": "objectId"
  },
  "productName": {
    "type": "autocomplete"
  },
  "sku": {
    "type": "autocomplete"
  },
  "variantName": {
    "type": "autocomplete"
  }
}

Atlas search index definition

{
  "mappings": {
    "dynamic": false,
    "fields": {
      "account": {
        "type": "objectId"
      },
      "productName": {
        "type": "autocomplete"
      },
      "sku": [
        {
          "analyzer": "lucene.keyword",
          "searchAnalyzer": "lucene.keyword",
          "type": "string"
        },
        {
          "type": "autocomplete"
        }
      ],
      "variantName": {
        "type": "autocomplete"
      }
    }
  }
}

Steps to Reproduce

  1. terraform apply

Output error

│ Error: error getting search index information: json: cannot unmarshal array into Go struct field IndexMapping.mappings.fields of type mongodbatlas.IndexField
│ 
│   with mongodbatlas_search_index.skus,
│   on mongodb.tf line 82, in resource "mongodbatlas_search_index" "skus":82: resource "mongodbatlas_search_index" "skus" {

Please note that the index has been manually updated via Atlas UI to get that index array definition.

@themantissa
Copy link
Collaborator

@stefanosala thank you - we'll have the team take a look and report back.

@themantissa
Copy link
Collaborator

@stefanosala this is being caused by a bug in the Atlas go client we use. The bug has been fixed so we'll need to update the provider to be able to use it. We will be working on that quickly.
INTMDB-251 internal ticket

@themantissa themantissa linked a pull request Aug 31, 2021 that will close this issue
10 tasks
@themantissa
Copy link
Collaborator

We have a pre-release of 1.0.1 ready - we'll release the GA version tomorrow. If you have time to try it out before then it's here: https://github.com/mongodb/terraform-provider-mongodbatlas/releases/tag/v1.0.1-pre.1

@themantissa
Copy link
Collaborator

Fixed in recent release 1.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants