创建索引shop

PUT /shop
{
     "settings": {
        "number_of_shards": 3,
        "number_of_replicas": 0
      }
}

修改http://81.69.251.148:9200/shop/_mapping post

{
    "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
        }
    }
}

shop添加数据http://81.69.251.148:9200/shop/_doc/1010 post

{
 "id":1010,
 "age":19,
 "username":"黄飞鸿10",
 "nickname":"隔壁老王",
 "money":88.8,
 "desc":"佛山黑帮大佬",
 "sex":1,
 "birthday":"2000-11-11",
 "face":"https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=d&word=%E9%BB%84%E9%A3%9E%E9%B8%BF%E5%9B%BE%E7%89%87&hs=0&pn=1&spn=0&di=160490&pi=0&rn=1&tn=baiduimagedetail&is=0%2C0&ie=utf-8&oe=utf-8&cl=2&lm=-1&cs=3990060156%2C884958364&os=815803032%2C634457065&simid=4189729889%2C704754146&adpicid=0&lpn=0&ln=30&fr=ala&fm=&sme=&cg=&bdtype=0&oriquery=%E9%BB%84%E9%A3%9E%E9%B8%BF%E5%9B%BE%E7%89%87&objurl=https%3A%2F%2Fgimg2.baidu.com%2Fimage_search%2Fsrc%3Dhttp%3A%2F%2Fpic1.58cdn.com.cn%2Fnowater%2F58toutiao%2Fbig%2Fn_v2d2ec0cc3af6e4128a2aba51fafc951b5.jpg%26refer%3Dhttp%3A%2F%2Fpic1.58cdn.com.cn%26app%3D2002%26size%3Df9999%2C10000%26q%3Da80%26n%3D0%26g%3D0n%26fmt%3Djpeg%3Fsec%3D1640098014%26t%3D55aa3cdb8ce034fd2a8377743139e016&fromurl=ippr_z2C%24qAzdH3FAzdH3Fgjof_z%26e3Bcb_z%26e3Bv54AzdH3FwrtAzdH3Fotg1jxAzdH3F2jpv5gf7sp1jpwts%3Fvtpyt1%3D8%26t1%3Dd090a8nb%26viwggjs%3D0%26pyrj%3Dx2%26usw2%3D8cdbc8d8mcdcc%26vwpj256y%3D0%26fiw6j%3D8&gsm=2&islist=&querylist=&dyTabStr=MCwzLDUsNiwyLDEsNCw3LDgsOQ%3D%3D"
}

查询数据 get

http://81.69.251.148:9200/shop/_search?q=desc:佛山&q=age:19

查询数据 post

http://81.69.251.148:9200/shop/_doc/_search

{
 "query":{
     "match":{
         "desc":"佛山"
     }
 }
}

查询所有数据 http://81.69.251.148:9200/shop/_doc/_search get

或者http://81.69.251.148:9200/shop/_doc/_search post 后续做分页过滤

{
 "query":{
     "match_all":{}
 }
}

查询某几个字段

{
 "query":{
     "match_all":{}
 },
 "_source":[
     "id",
     "nickname",
     "age"
 ]
}

分页

{
 "query":{
     "match_all":{}
 },
 "_source":[
     "id",
     "nickname",
     "age"
 ],
 "from":0,
 "size":2
}

 

posted on 2021-11-21 22:55  袁子弹  阅读(43)  评论(0编辑  收藏  举报