elasticsearch 创建一个搜索
1,打开kibana,创建一个索引:
PUT /db365_content
{
"mappings": {
"properties": {
"id": {
"type": "long"
},
"title": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
},
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
},
"other": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
},
"img": {
"type": "text"
},
"sort": {
"type": "long"
},
"tags": {
"type": "text"
}
}
}
}
2,插入一条数据:
POST /db365_content/_doc/566
{
"id":566,
"title":"vue动态九宫格抽奖源码",
"content":"基于VUE框架自定义动态数据抽奖奖品,九宫格转盘抽奖效果。特定:随机转动抽奖,自定义奖品个数,中奖弹窗等主要特点。",
"img":"http://img.tuoooo.com:813/5d1/5d1e9feeaff4f872fddb86e5dc1ae96e300_stjpg.jpg",
"other":"代码|网页特效|其它特效|vue动态九宫格抽奖源码",
"sort":0,
"tags":"随机抽奖"
}
3,查询测试:
POST /db365_content/_search
{
"query" : {
"match" : { "title" : "抽奖" }
},
"highlight" : {
"pre_tags" : ["<tag1>", "<tag2>"],
"post_tags" : ["</tag1>", "</tag2>"],
"fields" : {
"title" : {}
}
}
}
浙公网安备 33010602011771号