Skip to content
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

mongodbatlas_search_index does not allow for name changing #1613

Open
icco opened this issue Nov 9, 2023 · 3 comments
Open

mongodbatlas_search_index does not allow for name changing #1613

icco opened this issue Nov 9, 2023 · 3 comments
Labels
API-bug bug not_stale Not stale issue or PR

Comments

@icco
Copy link

icco commented Nov 9, 2023

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v1.5.7
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v4.67.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.23.0
+ provider registry.terraform.io/hashicorp/null v3.2.1
+ provider registry.terraform.io/hashicorp/random v3.5.1
+ provider registry.terraform.io/mongodb/mongodbatlas v1.12.2
+ provider registry.terraform.io/sumologic/sumologic v2.27.0

Terraform Configuration File

resource "mongodbatlas_search_index" "v2_initiative_props_search_index" {
  name            = "test"
  project_id      = var.atlas_project_id
  cluster_name    = "test"
  database        = "time-service"
  collection_name = "initiative_props"

  analyzer         = "lucene.standard"
  search_analyzer  = "lucene.standard"
  mappings_dynamic = false
  mappings_fields = jsonencode(
    {
      initiative = {
        dynamic = false
        fields = {
          client = {
            dynamic = false
            fields = {
              callSign = local.atlas_search_string_index_definition
              name     = local.atlas_search_string_index_definition
            }
            type = "document"
          }
          callSign = local.atlas_search_string_index_definition
          name     = local.atlas_search_string_index_definition
        }
        type = "document"
      }
      nickname = local.atlas_search_string_index_definition
      customerId = {
        type = "objectId"
      }
      userId = {
        type = "objectId"
      }
    }
  )

  analyzers = jsonencode(local.atlas_search_analyzers)
}

locals {
  laurel_standard_atlas_search_analyzer = {
    charFilters = [
      {
        type = "icuNormalize"
      },
      {
        mappings = {
          "("  = " "
          ")"  = " "
          ","  = " "
          "-"  = " "
          "."  = " "
          "/"  = " "
          ":"  = " "
          ";"  = " "
          "\\" = " "
          "_"  = " "
          "|"  = " "
        },
        type = "mapping"
      }
    ]
    name = "laurel.standard",
    tokenFilters = [
      {
        type = "icuFolding"
      },
      {
        type = "englishPossessive"
      },
      {
        type = "lowercase"
      },
      {
        type = "kStemming"
      }
    ],
    tokenizer = {
      type = "standard"
    }
  }

  laurel_standard_egrams_atlas_search_analyzer = {
    charFilters = [
      {
        type = "icuNormalize"
      },
      {
        mappings = {
          "("  = " "
          ")"  = " "
          ","  = " "
          "-"  = " "
          "."  = " "
          "/"  = " "
          ":"  = " "
          ";"  = " "
          "\\" = " "
          "_"  = " "
          "|"  = " "
        },
        type = "mapping"
      }
    ]
    name = "laurel.standard-egrams",
    tokenFilters = [
      {
        type = "icuFolding"
      },
      {
        type = "englishPossessive"
      },
      {
        type = "lowercase"
      },
      {
        type = "kStemming"
      },
      {
        maxGram         = 10,
        minGram         = 2,
        termNotInBounds = "include",
        type            = "edgeGram"
      }
    ],
    tokenizer = {
      type = "standard"
    }
  }

  laurel_exact_atlas_search_analyzer = {
    charFilters = [
      {
        type = "icuNormalize"
      }
    ]
    name = "laurel.exact"
    tokenFilters = [
      {
        type = "icuFolding"
      },
      {
        type = "lowercase"
      }
    ]
    tokenizer = {
      type = "whitespace"
    }
  }

  laurel_exact_egrams_atlas_search_analyzer = {
    charFilters = [
      {
        type = "icuNormalize"
      }
    ]
    name = "laurel.exact-egrams",
    tokenFilters = [
      {
        type = "icuFolding"
      },
      {
        type = "lowercase"
      },
      {
        maxGram         = 15,
        minGram         = 5,
        termNotInBounds = "include",
        type            = "edgeGram"
      }
    ],
    tokenizer = {
      type = "whitespace"
    }
  }

  atlas_search_analyzers = [
    local.laurel_standard_atlas_search_analyzer,
    local.laurel_standard_egrams_atlas_search_analyzer,
    local.laurel_exact_atlas_search_analyzer,
    local.laurel_exact_egrams_atlas_search_analyzer,
  ]

  atlas_search_string_index_definition = {
    analyzer = "laurel.standard-egrams"
    multi = {
      exact = {
        analyzer       = "laurel.exact-egrams"
        searchAnalyzer = "laurel.exact"
        type           = "string"
      }
    }
    searchAnalyzer = "laurel.standard"
    type           = "string"
  }
}

Steps to Reproduce

  1. Create a search index using the above code (or any other search index, doesn't matter in our experience)
  2. Change the name of the search index ("test_v2" for example)
  3. Apply

Expected Behavior

Either the search index should be recreated with the new name or the name should be changed.

Actual Behavior

It says it's going to change the name and doesn't.

Debug Output

N/A

Crash Output

N/A

Additional Context

N/A

References

N/A

Copy link
Contributor

github-actions bot commented Nov 9, 2023

Thanks for opening this issue! Please make sure you've followed our guidelines when opening the issue. In short, to help us reproduce the issue we need:

  • Terraform configuration file used to reproduce the issue
  • Terraform log files from the run where the issue occurred
  • Terraform Atlas provider version used to reproduce the issue
  • Terraform version used to reproduce the issue
  • Confirmation if Terraform OSS, Terraform Cloud, or Terraform Enterprise deployment

The ticket INTMDB-1275 was created for internal tracking.

@andreaangiolillo
Copy link
Collaborator

Hi @icco
Thanks for opening the issue. I was able to reproduce the bug. The issue is related to a bug with the Atlas endpoint rather than a bug with the provider. I am going to follow up internally to fix the endpoint. I will add an update as soon as the bug is fixed. Thanks

@Zuhairahmed
Copy link
Collaborator

Adding https://jira.mongodb.org/browse/CLOUDP-210605 for internal tracking purposes. As an update we are working on fix but this one is likely going to be several months away. Thanks for raising issue and will share next update when we can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API-bug bug not_stale Not stale issue or PR
Projects
None yet
Development

No branches or pull requests

3 participants