You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add Configurable Dynamic Indexing for Atlas Search (#3867)
* Add type_sets field to search_index resource
* Add type_sets and mappings_dynamic_config fields to singular and plural data source
* Refactor function into accepting multiple fields
* Add cannonical function for JSON
* Ensure mappings_dynamic_config is not set when mappings_dynamic is being used
* Refactor acceptance tests for less verbosity
* Add changelog entry
* Add documentation
* Extract hashtype implementation for better readability
* Address PR comments - documentation
* Add acceptance test step for omitted type_set
* Rephrase documentation for mappings_dynamic_config
* Address docs PR comment suggestions
* Update changelog sentences to be in 3rd person
* Refactor read operation for resource and single data source on mappings field
* Refactor canonical JSON function for simplicity purposes
* Remove unnecessary checks for resource read on mappings_dynamic and mappings_dynamic_config
resource/mongodbatlas_search_index: Adds `type_sets` field to support Atlas Search configurable dynamic type sets
3
+
```
4
+
5
+
```release-note:enhancement
6
+
resource/mongodbatlas_search_index: Adds `mappings_dynamic_config` (mutually exclusive with `mappings_dynamic`) to support object form of `mappings.dynamic`
7
+
```
8
+
9
+
```release-note:enhancement
10
+
data-source/mongodbatlas_search_index: Exposes `mappings_dynamic_config` and `type_sets`
11
+
```
12
+
13
+
```release-note:enhancement
14
+
data-source/mongodbatlas_search_indexes: Exposes `mappings_dynamic_config` and `type_sets` per result
Copy file name to clipboardExpand all lines: docs/data-sources/search_index.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,12 +35,16 @@ data "mongodbatlas_search_index" "test" {
35
35
*`collection_name` - Name of the collection the index is on.
36
36
*`database` - Name of the database the collection is in.
37
37
*`mappings_dynamic` - Flag indicating whether the index uses dynamic or static mappings.
38
+
*`mappings_dynamic_config` - JSON object for `mappings.dynamic` when Atlas returns an object (Please see the documentation for [dynamic and static mappings](https://www.mongodb.com/docs/atlas/atlas-search/index-definitions/#field-mapping-examples)). Mutually exclusive with `mappings_dynamic`.
38
39
*`mappings_fields` - Object containing one or more field specifications.
39
40
*`search_analyzer` - [Analyzer](https://docs.atlas.mongodb.com/reference/atlas-search/analyzers/#std-label-analyzers-ref) to use when searching the index.
40
41
*`synonyms` - Synonyms mapping definition to use in this index.
41
42
*`synonyms.#.name` - Name of the [synonym mapping definition](https://docs.atlas.mongodb.com/reference/atlas-search/synonyms/#std-label-synonyms-ref).
42
43
*`synonyms.#.source_collection` - Name of the source MongoDB collection for the synonyms.
43
44
*`synonyms.#.analyzer` - Name of the [analyzer](https://docs.atlas.mongodb.com/reference/atlas-search/analyzers/#std-label-analyzers-ref) to use with this synonym mapping.
44
45
*`stored_source` - String that can be "true" (store all fields), "false" (default, don't store any field), or a JSON string that contains the list of fields to store (include) or not store (exclude) on Atlas Search. To learn more, see [Stored Source Fields](https://www.mongodb.com/docs/atlas/atlas-search/stored-source-definition/).
46
+
*`type_sets` - Set of type set definitions (when present). Each item includes:
47
+
*`name` - Type set name.
48
+
*`types` - JSON array string describing the types for the set.
45
49
46
50
For more information see: [MongoDB Atlas API Reference.](https://docs.atlas.mongodb.com/atlas-search/) - [and MongoDB Atlas API - Search](https://docs.atlas.mongodb.com/reference/api/atlas-search/) Documentation for more information.
Copy file name to clipboardExpand all lines: docs/data-sources/search_indexes.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,13 +40,17 @@ data "mongodbatlas_search_indexes" "test" {
40
40
*`analyzers` - [Custom analyzers](https://docs.atlas.mongodb.com/reference/atlas-search/analyzers/custom/#std-label-custom-analyzers) to use in this index (this is an array of objects).
41
41
*`collection_name` - (Required) Name of the collection the index is on.
42
42
*`database` - (Required) Name of the database the collection is in.
43
-
*`mappings_dynamic` - Flag indicating whether the index uses dynamic or static mappings.
43
+
*`mappings_dynamic` - Flag indicating whether the index uses dynamic or static mappings. Mutually exclusive with `mappings_dynamic_config`.
44
+
*`mappings_dynamic_config` - JSON object for `mappings.dynamic` when Atlas returns an object (Please see the documentation for [dynamic and static mappings](https://www.mongodb.com/docs/atlas/atlas-search/index-definitions/#field-mapping-examples)). Mutually exclusive with `mappings_dynamic`.
44
45
*`mappings_fields` - Object containing one or more field specifications.
45
46
*`search_analyzer` - [Analyzer](https://docs.atlas.mongodb.com/reference/atlas-search/analyzers/#std-label-analyzers-ref) to use when searching the index.
46
47
*`synonyms` - Synonyms mapping definition to use in this index.
47
48
*`synonyms.#.name` - Name of the [synonym mapping definition](https://docs.atlas.mongodb.com/reference/atlas-search/synonyms/#std-label-synonyms-ref).
48
49
*`synonyms.#.source_collection` - Name of the source MongoDB collection for the synonyms.
49
50
*`synonyms.#.analyzer` - Name of the [analyzer](https://docs.atlas.mongodb.com/reference/atlas-search/analyzers/#std-label-analyzers-ref) to use with this synonym mapping.
50
51
*`stored_source` - String that can be "true" (store all fields), "false" (default, don't store any field), or a JSON string that contains the list of fields to store (include) or not store (exclude) on Atlas Search. To learn more, see [Stored Source Fields](https://www.mongodb.com/docs/atlas/atlas-search/stored-source-definition/).
52
+
*`type_sets` - Set of type set definitions (when present). Each item includes:
53
+
*`name` - Type set name.
54
+
*`types` - JSON array string describing the types for the set.
51
55
52
56
For more information see: [MongoDB Atlas API Reference.](https://docs.atlas.mongodb.com/atlas-search/) - [and MongoDB Atlas API - Search](https://docs.atlas.mongodb.com/reference/api/atlas-search/) Documentation for more information.
# mappings.dynamic as an object referencing a type set
127
+
mappings_dynamic_config = <<-EOF
128
+
{ "typeSet": "type_set_name" }
129
+
EOF
130
+
131
+
# Define the referenced type set
132
+
type_sets {
133
+
name = "type_set_name"
134
+
types = <<-EOF
135
+
[
136
+
{ "type": "string" }
137
+
]
138
+
EOF
139
+
}
140
+
}
141
+
```
142
+
116
143
## Argument Reference
117
144
118
145
*`type` - (Optional) Type of index: `search` or `vectorSearch`. Default type is `search`.
@@ -152,7 +179,7 @@ EOF
152
179
153
180
*`database` - (Required) Name of the database the collection is in.
154
181
155
-
*`mappings_dynamic` - Indicates whether the search index uses dynamic or static mapping. For dynamic mapping, set the value to `true`. For static mapping, specify the fields to index using `mappings_fields`
182
+
*`mappings_dynamic` - Indicates whether the search index uses dynamic or static mapping. For default dynamic mapping, set the value to `true`. For static mapping, specify the fields to index using `mappings_fields`. Mutually exclusive with `mappings_dynamic_config`.
156
183
157
184
*`mappings_fields` - attribute is required in search indexes when `mappings_dynamic` is false. This field needs to be a JSON string in order to be decoded correctly.
158
185
```terraform
@@ -190,6 +217,12 @@ EOF
190
217
EOF
191
218
```
192
219
220
+
*`mappings_dynamic_config` - (Optional) JSON object for `mappings.dynamic` when using configurable dynamic. See the MongoDB documentation for further information on [Static and Dynamic Mapping](https://www.mongodb.com/docs/atlas/atlas-search/define-field-mappings/#std-label-fts-field-mappings). Mutually exclusive with `mappings_dynamic`.
221
+
222
+
*`type_sets` - (Optional) One or more blocks defining configurable dynamic type sets. Atlas only persists/returns `typeSets` when `mappings.dynamic` is an object referencing a `typeSet` name.
223
+
*`name` - (Required) Name of the type set.
224
+
*`types` - (Optional) JSON array describing the types.
225
+
193
226
*`search_analyzer` - [Analyzer](https://docs.atlas.mongodb.com/reference/atlas-search/analyzers/#std-label-analyzers-ref) to use when searching the index. Defaults to [lucene.standard](https://docs.atlas.mongodb.com/reference/atlas-search/analyzers/standard/#std-label-ref-standard-analyzer)
194
227
*`synonyms` - Synonyms mapping definition to use in this index.
0 commit comments