curl -XPOST localhost:9200/photo -d '{
"photo": {
"properties": {
"id": {
"type": "String"
},
"title": {
"type": "String"
},
"category":{
"type": "String"
},
"uploader_name": {
"type": "String"
},
"uploader_id": {
"type": "String"
},
"keyword": {
"properties":{
"categoryId":{
"type": "String"
},
"content":{
"type": "String"
}
}
}
}
}
}'
curl -XPOST localhost:9200/photo/photo/1 -d '{
"id":"1",
"title":"北京天坛风景",
"uploader_name":"felayman",
"uploader_id":"1",
"keyword":[
{
"categoryId":"1",
"content":"北京"
},
{
"categoryId":"2",
"content":"天坛"
},
{
"categoryId":"3",
"content":"秋天"
},
{
"categoryId":"4",
"content":"旅游"
}
]
}'
curl -XPOST localhost:9200/photo/photo/2 -d '{
"id":"2",
"title":"河南",
"content":"旅游"
}
]
}'
curl -XGET 'localhost:9200/photo/photo/_search?pretty' -d '{
"aggregations": {
"agg": {
"terms": {
"field": "keyword.categoryId"
}
}
}
}'
curl -XPOST 'localhost:9200/photo/photo/2/_update' -d '{
"doc": {"keyword" : [{
"categoryId":"2",
"content":"旅游"
}]}
}';