## object类型
curl -XPUT http://ES_IP:ES_PORT/test_json_type?pretty -H 'Content-Type: application/json' -d '
{
"mappings" : {
"type" : {
"_all" : {
"enabled" : true
},
"properties" : {
"region" : {
"type" : "keyword"
},
"manager" : {
"type" : "object"
}
}
}
}
}'
curl -XPUT 'http://ES_IP:ES_PORT/test_json_type/type/1?pretty' -H 'Content-Type: application/json' -d'
{
"region": "US",
"manager": {
"age": 30,
"name": {
"first": "John",
"last": "Smith"
}
}
}
'
curl 'http://ES_IP:ES_PORT/test_json_type/_search'
## nested类型
curl -XPUT http://ES_IP:ES_PORT/test_json_array_type?pretty -H 'Content-Type: application/json' -d '
{
"mappings" : {
"type" : {
"_all" : {
"enabled" : true
},
"properties" : {
"group" : {
"type" : "keyword"
},
"user" : {
"type" : "nested"
}
}
}
}
}'
curl -XPUT 'http://ES_IP:ES_PORT/test_json_array_type/type/1?pretty' -H 'Content-Type: application/json' -d'
{
"group" : "fans",
"user" : [
{
"first" : "John",
"last" : "Smith"
},
{
"first" : "Alice",
"last" : "White"
}
]
}
'
curl 'http://ES_IP:ES_PORT/test_json_array_type/_search?pretty'
curl -XPUT http://ES_IP:ES_PORT/test_json_type?pretty -H 'Content-Type: application/json' -d '
{
"mappings" : {
"type" : {
"_all" : {
"enabled" : true
},
"properties" : {
"region" : {
"type" : "keyword"
},
"manager" : {
"type" : "object"
}
}
}
}
}'
curl -XPUT 'http://ES_IP:ES_PORT/test_json_type/type/1?pretty' -H 'Content-Type: application/json' -d'
{
"region": "US",
"manager": {
"age": 30,
"name": {
"first": "John",
"last": "Smith"
}
}
}
'
curl 'http://ES_IP:ES_PORT/test_json_type/_search'
## nested类型
curl -XPUT http://ES_IP:ES_PORT/test_json_array_type?pretty -H 'Content-Type: application/json' -d '
{
"mappings" : {
"type" : {
"_all" : {
"enabled" : true
},
"properties" : {
"group" : {
"type" : "keyword"
},
"user" : {
"type" : "nested"
}
}
}
}
}'
curl -XPUT 'http://ES_IP:ES_PORT/test_json_array_type/type/1?pretty' -H 'Content-Type: application/json' -d'
{
"group" : "fans",
"user" : [
{
"first" : "John",
"last" : "Smith"
},
{
"first" : "Alice",
"last" : "White"
}
]
}
'
curl 'http://ES_IP:ES_PORT/test_json_array_type/_search?pretty'