curl -XPOST http://localhost:9200/laker/_create/3 -H ‘Content-Type:application/json’ -d’
{“content”:“中韩渔警冲突调查:韩警平均每天扣1艘中国渔船”}
’
curl -XPOST http://localhost:9200/laker/_create/4 -H ‘Content-Type:application/json’ -d’
{“content”:“中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首”}
’
4.查询高亮
curl -XPOST http://localhost:9200/laker/_search -H ‘Content-Type:application/json’ -d’
{
“query” : { “match” : { “content” : “中国” }},
“highlight” : {
“pre_tags” : [“”, “”],
“post_tags” : [“”, “”],
“fields” : {
“content” : {}
}
}
}
’
结果
{
“took”: 796,
“timed_out”: false,
“_shards”: {
“total”: 1,
“successful”: 1,
“skipped”: 0,
“failed”: 0
},
“hits”: {
“total”: {
“value”: 2,
“relation”: “eq”
},
“max_score”: 0.642793,
“hits”: [
{
“_index”: “laker”,
“_type”: “_doc”,
“_id”: “3”,
“_score”: 0.642793,
“_source”: {
“content”: “中韩渔警冲突调查:韩警平均每天扣1艘中国渔船”
},
“highlight”: {
“content”: [
“中韩渔警冲突调查:韩警平均每天扣1艘中国渔船”
]
}
},
{
“_index”: “laker”,
“_type”: “_doc”,
“_id”: “4”,
“_score”: 0.642793,
“_source”: {
“content”: “中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首”
},
“highlight”: {
“content”: [
“中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首”
]
}
}
]
}
}