自己建设网站流程,电子商务网站开发环境,有了 ftp服务器密码 怎么改网站,代理公司名字取什么名目录 场景#xff1a;
结果格式化显示#xff1a;
验证服务启动#xff1a; 单个参数变量查询#xff1a;
分页查询#xff1a;
日期范围查询:
must中单个参数条件查询
must中多个参数条件查询 使用filter过滤查询 使用sort过滤查询
总结#xff1a; 场景#xf…目录 场景
结果格式化显示
验证服务启动 单个参数变量查询
分页查询
日期范围查询:
must中单个参数条件查询
must中多个参数条件查询 使用filter过滤查询 使用sort过滤查询
总结 场景 线上存在浏览器禁止访问es的9200端口的情况只能在es的服务器上去操作因此用到curl命令下面总结一波、 结果格式化显示 centos 安装 jqyum isstall jq 验证服务启动 curl -X GET http://192.168.xx.xxx:9200 -u username:password | jq . 单个参数变量查询 curl -X POST http://192.168.xx.xxx:9200/esbizlog/_search \ -H Content-Type:application/json\ -u username:password \ -d { query:{ match_phrase:{ gisq_request_id:e8bcf64e-7ed9-4a94-9b54-85dd1e277790} } } | jq . 分页查询 curl -X POST http://192.168.16.155:9200/esbizlog/_search \ -H Content-Type:application/json \ -u username:password \ -d { from:1, size:2 } | jq . 注意分页变量from和size是和query平级不能放在query里面
日期范围查询: curl -X POST http://192.168.xx.xxx:9200/esbizlog/_search \ -H Content-Type:application/json \ -u username:password \ -d { query: { range: { datetime: { gt: 2023-06-04 23:59:59, lt: 2023-06-05 12:00:00 } } }, from: 1, size: 3 } | jq . must中单个参数条件查询 curl -X POST http://192.168.xx.xxx:9200/esbizlog/_search -H Content-Type:application/json -u elastic:elasticgisquest.com -d {query:{ bool:{ must:{match_phrase:{gisq_request_id:e8bcf64e-7ed9-4a94-9b54-85dd1e277790}} } }} | jq . must中多个参数条件查询 curl -X POST http://192.168.xx.xxx:9200/esbizlog/_search -H Content-Type:application/json -u elastic:elasticgisquest.com -d {query:{ bool:{ must:[ {match_all:{} }, {range: { datetime: { gt: 2023-06-04 23:59:59, lt: 2023-06-05 12:00:00 } } } ] }}} | jq . 注must中如果单个参数查询则后面不用数组形式嵌套如果多个参数则需要用数组形式嵌套 使用filter过滤查询 curl -X POST http://192.168.xx.xxx:9200/esbizlog/_search \ -H Content-Type:application/json \ -u elastic:elasticgisquest.com \ -d { query:{ bool:{ filter:{ match:{ gisq_request_id:f7bbae56-405a-4f71-8827-9fff821a9679} } } },from:0,size:2 } | jq . 注使用filter时要将filter放到bool内部使用must外部并列否则会报错 unknown field [filter] 使用sort过滤查询 curl -X POST http://192.168.xx.xxx:9200/esbizlog/_search \ -H Content-Type:application/json \ -u elastic:elasticgisquest.com \ -d { query:{ range: { datetime: { gt: 2023-06-04 23:59:59, lt: 2023-06-05 12:00:00 } } }, from:0, size:10, sort:{ datetime:{order:desc} } } | jq . 总结
1.上面便是es的常用的查询其中查询单个字段直接匹配查询即可对于filter查询通常要放到bool里面位置和must并列。
2.curl命令 curl -x [请求方式] “url” -H [请求头参数设置] -u 【用户账号密码】设置 -d 请求提设置