Skip to content

Commit 600669f

Browse files
committed
Update documentation
1 parent 6497e3f commit 600669f

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

docs/contents/nest/indices/put-mapping.markdown

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,41 +61,37 @@ You can persist this mapping by simpling calling
6161

6262
You can also create mappings on the fly:
6363

64-
var typeMapping = new TypeMapping(Guid.NewGuid().ToString("n"));
65-
var property = new TypeMappingProperty
64+
var indexDefinition = new RootObjectMapping
6665
{
67-
Type = "multi_field"
66+
Properties = new Dictionary<PropertyNameMarker, IElasticType>(),
67+
Name = indexName
6868
};
6969

70-
var primaryField = new TypeMappingProperty
70+
var property = new StringMapping
7171
{
72-
Type = "string",
7372
Index = "not_analyzed"
7473
};
7574

76-
var analyzedField = new TypeMappingProperty
75+
var analyzedField = new StringMapping
7776
{
78-
Type = "string",
7977
Index = "analyzed"
8078
};
8179

82-
property.Fields = new Dictionary<string, TypeMappingProperty>();
83-
property.Fields.Add("name", primaryField);
8480
property.Fields.Add("name_analyzed", analyzedField);
81+
indexDefinition.Properties.Add("name", property);
82+
this.ConnectedClient.Map<object>(x => x.InitializeUsing(indexDefinition));
8583

86-
typeMapping.Properties.Add("name", property);
87-
this.ConnectedClient.Map(typeMapping);
8884

8985
## Multifield Mapping
9086
To create multifield type you can use following example.
9187

9288
var result = this._client.Map<ElasticsearchProject>(m => m
9389
.Properties(props => props
94-
.MultiField(s => s
90+
.String(s => s
9591
.Name(p => p.Name)
9692
.Path(MultiFieldMappingPath.Full)
93+
.Index(FieldIndexOption.not_analyzed)
9794
.Fields(pprops => pprops
98-
.String(ps => ps.Name(p => p.Name).Index(FieldIndexOption.not_analyzed))
9995
.String(ps => ps.Name(p => p.Name.Suffix("searchable")).Index(FieldIndexOption.analyzed))
10096
)
10197
))

0 commit comments

Comments
 (0)