Elasticsearch-DLS搜索
一、数据准备
建立索引shop(名字随意)
手动建立mappings
POST /shop/_mapping
{
"properties": {
"id": {
"type": "long"
},
"age": {
"type": "integer"
},
"username": {
"type": "keyword"
},
"nickname": {
"type": "text",
"analyzer": "ik_max_word"
},
"money": {
"type": "float"
},
"desc": {
"type": "text",
"analyzer": "ik_max_word"
},
"sex": {
"type": "byte"
},
"birthday": {
"type": "date"
},
"face": {
"type": "text",
"index": false
}
}
}
录入数据
POST /shop/_doc/_bulk
{"index":{}}
{"id":1001,"age":18,"username":"imoocAmazing","nickname":"慕课网","money":88.8,"desc":"我在慕课网学习java和前端,学习到了很多知识","sex":0,"birthday":"1992-12-24","face":"https://www.imooc.com/static/img/index/logo.png"}
{"index":{}}
{"id":1002,"age":19,"username":"justbuy","nickname":"周杰棍","money":77.8,"desc":"今天上下班都很堵,车流量很大","sex":1,"birthday":"1993-01-24","face":"https://www.imooc.com/static/img/index/logo.png"}
{"index":{}}
{"id":1003,"age":20,"username":"bigFace","nickname":"飞翔的巨鹰","money":66.8,"desc":"慕课网团队和导游坐飞机去海外旅游,去了新马泰和欧洲","sex":1,"birthday":"1996-01-14","face":"https://www.imooc.com/static/img/index/logo.png"}
{"index":{}}
{"id":1004,"age":22,"username":"flyfish","nickname":"水中鱼","money":55.8,"desc":"昨天在学校的池塘里,看到有很多鱼在游泳,然后就去慕课网上课了","sex":0,"birthday":"1988-02-14","face":"https://www.imooc.com/static/img/index/logo.png"}
{"index":{}}
{"id":1005,"age":25,"username":"gotoplay","nickname":"ps游戏机","money":155.8,"desc":"今年生日,女友送了我一台playstation游戏机,非常好玩,非常不错","sex":1,"birthday":"1989-03-14","face":"https://www.imooc.com/static/img/index/logo.png"}
{"index":{}}
{"id":1006,"age":19,"username":"missimooc","nickname":"我叫小慕","money":156.8,"desc":"我叫凌云慕,今年20岁,是一名律师,我在琦䯲星球做演讲","sex":1,"birthday":"1993-04-14","face":"https://www.imooc.com/static/img/index/logo.png"}
{"index":{}}
{"id":1007,"age":19,"username":"msgame","nickname":"gamexbox","money":1056.8,"desc":"明天去进货,最近微软处理很多游戏机,还要买xbox游戏卡带","sex":1,"birthday":"1985-0