mongodb / awscdk-resources-mongodbatlas

MongoDB Atlas AWS CDK Resources
Apache License 2.0
32 stars 15 forks source link

[Bug]: Wrong types for charFilters and tokenFilters in ApiAtlasFtsAnalyzersViewManual #292

Open mcelkys opened 1 week ago

mcelkys commented 1 week ago

Is there an existing issue for this?

CDK package version

3.6.0

CFN Resource version

N/A

CFN Resource Region

eu-west-2

Current Behavior

ApiAtlasFtsAnalyzersViewManual type contains incorrect definitions for charFilters and tokenFilters.

https://constructs.dev/packages/awscdk-resources-mongodbatlas/v/3.6.0/api/ApiAtlasFtsAnalyzersViewManual?lang=typescript

charFilters: string[];
tokenFilters: string[];

These should be object arrays:

https://www.mongodb.com/docs/atlas/atlas-search/analyzers/character-filters/ https://www.mongodb.com/docs/atlas/atlas-search/analyzers/token-filters/

AWS CDK code to reproduce the issue

new CfnSearchIndex(scope, id, {
  name: name,
  clusterName: clusterName,
  collectionName: collectionName,
  database: database,
  analyzers: [
    {
      name: "custom.english",
      tokenizer: { type: "standard" },
      tokenFilters: [
        { type: "englishPossessive" },
        { type: "lowercase" },
        { type: "porterStemming" },
      ]
    }
  ]
});

Steps To Reproduce

  1. Have a stack that creates a search index with custom analyzers
  2. Run cdk deploy MySearchStack
  3. Deployment fails

cdk synth

Resources:
  roadevAtlasRegistrationSearchIndex:
    Type: MongoDB::Atlas::SearchIndex
    Properties:
      Analyzers:
        - Name: english.companyName
          TokenFilters:
            - type: englishPossessive
            - type: lowercase
            - type: porterStemming
          Tokenizer:
            Type: standard
        - CharFilters:
            - type: mapping
              mappings:
                "'": ""
                Mac: Mc
                mac: mc
          Name: keyword.fullname
          TokenFilters:
            - type: lowercase
          Tokenizer:
            Type: keyword
      ClusterName: roa-lower-cluster
      CollectionName: registrations
      Database: roa-dev
      ProjectId:
        Fn::ImportValue: lowerAtlasProjectId
      Mappings:
        Dynamic: false
        Fields: '{"assignors":{"type":"document","dynamic":false,"fields":{"companyName":[{"type":"string","analyzer":"english.companyName"},{"type":"token","normalizer":"lowercase"}],"companyNumber":{"type":"string","analyzer":"lucene.keyword","searchAnalyzer":"lucene.keyword"},"dateOfBirth":{"type":"document","dynamic":false,"fields":{"month":{"type":"number","representation":"int64"},"year":{"type":"number","representation":"int64"}}},"fullname":[{"type":"string","analyzer":"keyword.fullname"},{"type":"token","normalizer":"lowercase"}]}},"number":{"type":"string","analyzer":"lucene.keyword","searchAnalyzer":"lucene.keyword"},"registrationStatus":{"type":"number","representation":"int64"},"registeredDateTime":{"type":"date"}}'
      Name: roa-registration
      Synonyms:
        - Analyzer: english.companyName
          Name: company-name-synonyms
          Source:
            Collection: synonyms
    Metadata:
      aws:cdk:path: dev-AtlasSearchIndexStack/roa-devAtlasRegistrationSearchIndex
  rspdevAtlasRegistrationSearchIndex:
    Type: MongoDB::Atlas::SearchIndex
    Properties:
      Analyzers:
        - Name: english.companyName
          TokenFilters:
            - type: englishPossessive
            - type: lowercase
            - type: porterStemming
          Tokenizer:
            Type: standard
        - CharFilters:
            - type: mapping
              mappings:
                "'": ""
                Mac: Mc
                mac: mc
          Name: keyword.fullname
          TokenFilters:
            - type: lowercase
          Tokenizer:
            Type: keyword
      ClusterName: rsp-lower-cluster
      CollectionName: registrations
      Database: rsp-dev
      ProjectId:
        Fn::ImportValue: lowerAtlasProjectId
      Mappings:
        Dynamic: false
        Fields: '{"providers":{"type":"document","dynamic":false,"fields":{"companyName":[{"type":"string","analyzer":"english.companyName"},{"type":"token","normalizer":"lowercase"}],"companyNumber":{"type":"string","analyzer":"lucene.keyword","searchAnalyzer":"lucene.keyword"},"dateOfBirth":{"type":"document","dynamic":false,"fields":{"month":{"type":"number","representation":"int64"},"year":{"type":"number","representation":"int64"}}},"fullname":[{"type":"string","analyzer":"keyword.fullname"},{"type":"token","normalizer":"lowercase"}]}},"number":{"type":"string","analyzer":"lucene.keyword","searchAnalyzer":"lucene.keyword"},"registrationStatus":{"type":"number","representation":"int64"},"registeredDateTime":{"type":"date"}}'
      Name: rsp-registration
      Synonyms:
        - Analyzer: english.companyName
          Name: company-name-synonyms
          Source:
            Collection: synonyms
    Metadata:
      aws:cdk:path: dev-AtlasSearchIndexStack/rsp-devAtlasRegistrationSearchIndex
  CDKMetadata:
    Type: AWS::CDK::Metadata
    Properties:
      Analytics: v2:deflate64:H4sIAAAAAAAA/zPSMzQx1TNQTCwv1k1OydbNyUzSqw4uSUzO1nFOywtKLc4vLUpOrdXJy09J1csq1i8ztNAzNANqyCrOzNQtKs0rycxN1QuC0ABjogPWTQAAAA==
    Metadata:
      aws:cdk:path: dev-AtlasSearchIndexStack/CDKMetadata/Default
Parameters:
  BootstrapVersion:
    Type: AWS::SSM::Parameter::Value<String>
    Default: /cdk-bootstrap/hnb659fds/version
    Description: Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]
Rules:
  CheckBootstrapVersion:
    Assertions:
      - Assert:
          Fn::Not:
            - Fn::Contains:
                - - "1"
                  - "2"
                  - "3"
                  - "4"
                  - "5"
                - Ref: BootstrapVersion
        AssertDescription: CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.

Code of Conduct

github-actions[bot] commented 1 week ago

Thanks for opening this issue! Please make sure to provide the following information to help us reproduce the issue:

Thanks for opening this issue. The ticket CLOUDP-254069 was created for internal tracking.

Zuhairahmed commented 1 week ago

hi @mcelkys we are investigating to reproduce this issue on our end. will revert back with updates, but may take some time to get back to you. appreciate your patience in advance!