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

Duplicated index when updating a search index #745

Closed
matsekroth opened this issue Oct 2, 2023 · 6 comments
Closed

Duplicated index when updating a search index #745

matsekroth opened this issue Oct 2, 2023 · 6 comments
Labels

Comments

@matsekroth
Copy link

CloudFormation Template (CDK)

const assetSearchIndex = new CfnSearchIndex(this, "AssetSearchIndex", {
      projectId: atlasProject.getAtt("Id").toString(),
      clusterName: props.clusterName,
      database: props.databaseName,
      collectionName: "collectionName",
      name: "searchFilterIndex",
      mappings: {
        fields: [
          "assetId:string",
          "companyId:string",
          "currentLocation.address.addressLine:string",
          "ownershipDetails.assetName:string",
          "productInformation.articleNumber:string",
          "productInformation.serialNumber:string",
          "productInformation.categoryName:string",
          "productInformation.subcategoryName:string",
          "productInformation.categoryName:stringFacet",
          "productInformation.subcategoryName:stringFacet",
          "runtime.motor:number",
          "tags.tag:string",
          "tags.tagCategory:string",
        ],
      },
    });

CloudFormation Template

"AssetSearchIndex": {
   "Type": "MongoDB::Atlas::SearchIndex",
   "Properties": {
    "ClusterName": "FleetCluster",
    "CollectionName": "collectionName",
    "Database": "db-name",
    "ProjectId": {
     "Fn::GetAtt": [
      "AtlasProject",
      "Id"
     ]
    },
    "Mappings": {
     "Fields": [
      "assetId:string",
      "companyId:string",
      "currentLocation.address.addressLine:string",
      "ownershipDetails.assetName:string",
      "productInformation.articleNumber:string",
      "productInformation.serialNumber:string",
      "productInformation.categoryName:string",
      "productInformation.subcategoryName:string",
      "productInformation.categoryName:stringFacet",
      "productInformation.subcategoryName:stringFacet",
      "runtime.motor:number",
      "tags.tag:string",
      "tags.tagCategory:string"
     ]
    },
    "Name": "searchFilterIndex"
   },
   "DependsOn": [
    "AtlasCluster"
   ],
   "Metadata": {
    "aws:cdk:path": "dev/AssetSearchIndex"
   }
  }

Steps to Reproduce

Create a searchIndex in cloudformation/cdk and add a bunch of fields and deploy this to MongoDB.
The index is created.
Add a few new fields in the previously created index and deploy again.
This will cause the issue.

Expected Behavior

The existing index should have been updated with the two new fields.

Actual Behavior

I created the index first without the last two fields "tags.tag:string" and "tags.tagCategory:string", then I tried to run a query and realized I had missed these two and then added these two fields and tried to update the index through ckd deploy and received the error that the index was duplicated.

Error: Error: The stack named stack-name failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: 400 (request "ATLAS_FTS_DUPLICATE_INDEX") Duplicate Index." (RequestToken: token, HandlerErrorCode: InvalidRequest)

Additional Context

Some details are omitted in the error due to internal company information. Please reach out to me through email if you need more detailed information about the setup or errors.

There is a azure devops pipeline which executes the cdk project and deploys cdk to aws to update mongodb. This is setup properly and has been running for some time, and multiple updates has been done through this. So the error message pasted above is from the result from the azure devops pipeline.

package.json version numbers:

"aws-cdk": "2.79.1"
"aws-cdk-lib": "2.79.1"
"awscdk-resources-mongodbatlas": "1.2.0"

References

None

@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2023

Thanks for opening this issue. The ticket INTMDB-1163 was created for internal tracking.

@Adelmar92
Copy link
Contributor

hello @matsekroth this ive creatd a pull request for this one, the Mappings property was defined as CreateOnly, this means that cloud formation will try to replace the resource if this property is modified, ive changed this removing the property as CreateOnly (also there is a bug on cloud formation it seems that is not updating the docs correctly for this specific property, so is still set as NotInterrupt, im informing this to Cloud Formation)

@matsekroth
Copy link
Author

Super @Adelmar92!
Please inform me when this is deployed and ready in AWS so I can test again and verify that it works 👍

@Adelmar92
Copy link
Contributor

@matsekroth this fix should have been published in the 11-10-2023 version, can you please test it?

@Zuhairahmed
Copy link
Collaborator

Zuhairahmed commented Oct 26, 2023

hi @matsekroth just double checking if you had a chance to test this yet? if so feel free to close out this issue. thank you

@Zuhairahmed
Copy link
Collaborator

Hi resolving this issue as fixed was released. Let us know if you need anything else

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

No branches or pull requests

3 participants