Skip to content

Commit

Permalink
add type field
Browse files Browse the repository at this point in the history
  • Loading branch information
lantoli committed Nov 7, 2023
1 parent 32803ac commit 5cff810
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion mongodbatlas/resource_mongodbatlas_search_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ func returnSearchIndexSchema() map[string]*schema.Schema {
Type: schema.TypeBool,
Optional: true,
},
"type": {
Type: schema.TypeString,
Optional: true,
},
}
}

Expand Down Expand Up @@ -181,6 +185,10 @@ func resourceMongoDBAtlasSearchIndexUpdate(ctx context.Context, d *schema.Resour
return diag.Errorf("error getting search index information: %s", err)
}

if d.HasChange("type") {
searchIndex.Type = stringPtr(d.Get("type").(string))
}

if d.HasChange("analyzer") {
searchIndex.Analyzer = stringPtr(d.Get("analyzer").(string))
}
Expand Down Expand Up @@ -272,6 +280,10 @@ func resourceMongoDBAtlasSearchIndexRead(ctx context.Context, d *schema.Resource
return diag.Errorf("error setting `index_id` for search index (%s): %s", d.Id(), err)
}

if err := d.Set("type", searchIndex.Type); err != nil {
return diag.Errorf("error setting `type` for search index (%s): %s", d.Id(), err)
}

if err := d.Set("analyzer", searchIndex.Analyzer); err != nil {
return diag.Errorf("error setting `analyzer` for search index (%s): %s", d.Id(), err)
}
Expand All @@ -283,7 +295,7 @@ func resourceMongoDBAtlasSearchIndexRead(ctx context.Context, d *schema.Resource
}

if err := d.Set("analyzers", searchIndexMappingFields); err != nil {
return diag.Errorf("error setting `analyzer` for search index (%s): %s", d.Id(), err)
return diag.Errorf("error setting `analyzers` for search index (%s): %s", d.Id(), err)
}
}

Expand Down Expand Up @@ -348,6 +360,7 @@ func resourceMongoDBAtlasSearchIndexCreate(ctx context.Context, d *schema.Resour
clusterName := d.Get("cluster_name").(string)
dynamic := d.Get("mappings_dynamic").(bool)
searchIndexRequest := &admin.ClusterSearchIndex{
Type: stringPtr(d.Get("type").(string)),
Analyzer: stringPtr(d.Get("analyzer").(string)),
Analyzers: unmarshalSearchIndexAnalyzersFields(d.Get("analyzers").(string)),
CollectionName: d.Get("collection_name").(string),
Expand Down

0 comments on commit 5cff810

Please sign in to comment.