Created
July 8, 2014 07:19
-
-
Save tomlokhorst/d9d19559f7e2ab3610a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Current (C# 5) syntax | |
var request = new CreateIndexRequest("new-index-name") | |
{ | |
IndexSettings = new IndexSettings | |
{ | |
Settings = new Dictionary<string, object> | |
{ | |
{"index.settings", "value"} | |
}, | |
Mappings = new List<RootObjectMapping> | |
{ | |
new RootObjectMapping | |
{ | |
Name = "my_root_object", | |
Properties = new Dictionary<PropertyNameMarker, IElasticType> | |
{ | |
{"my_field", new StringMapping() { Analyzer = "default" } } | |
} | |
} | |
} | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C# 6 dictionary initializer syntax | |
var request = new CreateIndexRequest("new-index-name") | |
{ | |
IndexSettings = new IndexSettings | |
{ | |
Settings = { | |
"index.settings" = "value" | |
}, | |
Mappings = { | |
new RootObjectMapping | |
{ | |
Name = "my_root_object", | |
Properties = { | |
"my_field" = new StringMapping() { Analyzer = "default" } | |
} | |
} | |
} | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C# 6 member initializer syntax | |
var request = new CreateIndexRequest("new-index-name") | |
{ | |
IndexSettings = new IndexSettings | |
{ | |
Settings = { | |
$index_settings = "value" // Custom made-up serializer maps _ to . | |
}, | |
Mappings = { | |
new RootObjectMapping | |
{ | |
Name = "my_root_object", | |
Properties = { | |
$my_field = new StringMapping() { Analyzer = "default" } | |
} | |
} | |
} | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"settings": { | |
"index.settings": "value" | |
}, | |
"mappings": { | |
"my_root_object": { | |
"properties": { | |
"my_field": { "analyzer": "default" } | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment