curl [ -s][ -g][ -X<REST Verb>][ -H 'Content-Type: application/json'] ':/[/Type][/ID]/_search?pretty&q='
-s
:不输出查询的时间等信息-g
:转义用
:REST请求的,get/post/put/delete
:节点ip,本机为localhost
:阶段端口,es为9200
:索引名,支持通配符*
:索引类型,一个index只有1个type,可不输入
:操作对象的ID号,可不输入q
:前面加&,后面加查询语句参数 | 作用 | 备注 |
---|---|---|
q | 查询字符串 | |
s(sort) | 排序 | |
from | 从命中的hits开始返回 | 默认为0 |
size | 返回的hits数量 | 默认为10 |
_source_include | 查询包含某些source字段的文档 | |
_source_exclude | 查询不包含某些source字段的文档 | |
timeout | 搜索超时,将在指定执行时间内查到的hits返回 | 默认无超时 |
default_field | 指定字段,未指定字段前缀时返回所有字段 | 默认为index.query.default_field |
default_operator | 指定查询运算符 | 未指定,默认为or |
analyzer | 指定用于分析查询字符串的分析器 | |
_source | 布尔设定是否使用_source字段检索 | false禁用 |
analyze_wildcard | 布尔设定是否模糊查询(通配符、前缀) | 默认false禁用 |
pretty | json | 默认为true |
查询字符串q=[..] |
_exists_:title |
是否存在 |
status:active | 查询status字段是active的文档 | |
title:(quick OR brown) | 查询title字段是quick或brown的文档 | |
author:“John Smith” | 查询author字段是John Smith的文档,因为有空格,所以要用引号包起来 | |
date:[2012-01-01 TO 2012-12-31] | 查询date字段是active的文档 | |
count:[10 TO *] | 查询count字段从10开始(增长)的文档 | |
count:>=10 | 查询count字段大于等于10的文档 |
curl localhost:9200/_cat/nodes?v
curl localhost:9200/_cat/health?v
curl 'localhost:9200/_cat/indices?v&s=index'
curl 'localhost:9200/_cat/indices/dayapi*?v&s=index'
*
:通配符curl 'localhost:9200/dayapi*?pretty'
curl 'localhost:9200/dayapi*/_search?pretty&q=_exists_:MULT'
curl 'localhost:9200/dayapi*/_search?pretty&q=TESTID:123'
curl 'localhost:9200/dayapi*/_search?pretty&q=TESTID:123&size=3'
curl 'localhost:9200/dayapi*/_search?pretty&q=TESTID:123&from=2&size=3'
curl 'localhost:9200/dayapi*/_search?pretty&q=TESTID:123&sort=TIME:desc'
curl 'localhost:9200/dayapi*/_search?pretty&analyze_wildcard&q=TESTID:123'
curl 'localhost:9200/dayapi*/_search?pretty&q=VAL:<200'
curl 'localhost:9200/dayapi*/_search?pretty&_source=false'
curl 'localhost:9200/dayapi*/_search?pretty&_source_includes=TIME,VAL'
curl -g 'localhost:9200/dayapi*/_search?pretty&q=(SOLAR:1%20AND%20CENTRAL:1)'
AND
一定要大写,不然识别不出%20
转义后的空格分隔字段名:值
表示curl -g 'localhost:9200/dayapi*/_search?pretty&q=TIME:[2019-05%20TO%202019-06]'
date
,integer
,double
等curl -XPOST localhost:19200/dayapi*/_close
curl -XPOST localhost:19200/dayapi*/_open
curl -XPOST 'localhost:19200/dayapi*/_delete_by_query?pretty&q=TESTID:781128
curl -H "Content-Type: application/json" -XPUT 'http://localhost:9200/dayapi2/' -d '
{
"mappings" : {
"market_api" : {
"properties" : {
"prop_1" : {
"type" : "keyword"
},
"prop_2" : {
"type" : "double"
},
"prop_3" : {
"type" : "keyword"
},
"prop_4" : {
"type" : "integer"
}
}
}
}
}'
curl -XDELETE 'http://localhost:9200/dayapi'
curl -H "Content-Type: application/json" -XPOST 'http://localhost:9200/_reindex' -d '
{
"source": {
"index": "index1"
},
"dest": {
"index": "index2"
}
}'
curl -XPOST 'localhost:9200/_aliases' -d '{"actions": [{"add": {"index": "dayapi", "alias": "dayapi123"}}]}
curl -XGET "http://localhost:9200/dayapi/_mapping?pretty"
思路来源:https://blog.csdn.net/Misaki_root/article/details/101203647
扩大最大查询结果窗口
curl -H "Content-Type: application/json" -XPUT localhost:9200/dayapi/_settings -d '{ "index.max_result_window" :"1000000"}'
参考文章
https://www.cnblogs.com/daynote/p/11076965.html