ElasticSearch——使用备忘

普通插入数据

http://xxxx:9200/user_list/_doc
    {
      "id":101,
      "analyzer": 1,
      "userId": "userId_001",
      "userMobile": "13544789621",
      "uploadVersion": "1.0.0",
      "friendMobile": "13544789621",
      "friendName": "zhansan",
      "createTime":1663762883739,
      "updateTime":1663762883739
    }

 

 

常规查询

GET
http://xxxxx:9200/user_list/_search

 

添加模板

POST
http://xxxxx:9200/user_list/_scripts/user_list_template
{
"script": {
"lang": "mustache",
"source": "{\"query\":{\"bool\":{\"must\":{{#toJson}}clauses{{/toJson}},\"filter\":{{#toJson}}filters{{/toJson}}}},\"sort\":{{#toJson}}sorts{{/toJson}},\"from\":\"{{from}}{{^from}}0{{/from}}\",\"size\":\"{{size}}{{^size}}10{{/size}}\"}"
}
}

 

查看模板

GET
http://xxxxx:9200/user_list/_scripts/user_list_template

 

用模板查询

POST
http://xxxxx:9200/user_list/_search/template
{"id":"user_list_template","params":{"clauses":[],"filters":[],"sorts":[]}}

 



 

posted @ 2023-07-28 18:50  会飞的斧头  阅读(12)  评论(0编辑  收藏  举报