1.查看所有索引:curl ‘localhost:9200/_cat/indices?v’
2.查看test索引(后缀美化:?pretty):curl -XGET ‘localhost:9200/test/search?pretty’
3.查看test_下所有索引:curl -XGET 'localhost:9200/test/_search?pretty’
4.模糊查询(含有student)索引名称:curl 'localhost:9200/cat/indices?v’ | grep ‘student’
5.匹配ip等于哪个字段 只显示那个字段 curl -XPOST 'localhost:9200/test/_search?pretty’ -d’{“query”:{“match”:{“ip”:“2.2.2.2”}},"_source":[“ip”,“name”]}’
6. must 相当于and(与)should相当于or: curl -XPOST ‘localhost:9200/test/_search?pretty’ -d ‘{“query”:{“bool”:{“must”:[{“term”:{“name”: “123”}},{“term”:{“type”: “3”}}]}}}’
7.时间范围以及时间排序取几条: curl -XGET ‘localhost:9200/test/_search?pretty’ -d ‘{“query”:{“range”: {“start_time”:{“lte”:1632363010000,“gte”:1610467210000 }}},"source":[“id”,“name”,“score”,“type”,“start_time”],“sort”:[{“start_time”:{“order”:“asc”}}],“from”:1,“size”:4 }’
8.取两条数据:curl -XGET 'localhost:9200/test*/_search?pretty’ -d ‘{“from”:1,“size”:2 }’
Es基本操作命令
最新推荐文章于 2022-10-18 11:31:12 发布