常用命令
添加索引:
curl -XPUT 'http://192.168.0.227:9200/megacorp/employee/2' -d '
{
"first_name" : "Douglas",
"last_name" : "Fir",
"age" : 35,
"about": "I like to build cabinets",
"interests": [ "forestry" ]
}'
查询索引:
curl -XGET 'http://192.168.0.227:9200/megacorp/employee/1?pretty'
检索所有雇员:
curl -XGET '192.168.0.227:9200/megacorp/employee/_search?pretty'
条件搜索
curl -XGET '192.168.0.227:9200/megacorp/employee/_search?q=last_name:Smith&pretty'
查询表达式
curl -XGET '192.168.0.227:9200/megacorp/employee/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query" : {
"match" : {
"last_name" : "Smith"
}
}
} '
过滤器
curl -XGET '192.168.0.227:9200/megacorp/employee/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query" : {
"bool": {
"must": {
"match" : {
"last_name" : "smith"
}
},
"filter": {
"range" : {
"age" : { "gt" : 30 }
}
}
}
}
}
'
全文检索, 搜索下所有喜欢攀岩(rock climbing)的雇员
curl -XGET '192.168.0.227:9200/megacorp/employee/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query" : {
"match" : {
"about" : "rock climbing"
}
}
}
'
高亮搜索
curl -XGET '192.168.0.227:9200/megacorp/employee/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query" : {
"match_phrase" : {
"about" : "rock climbing"
}
},
"highlight": {
"fields" : {
"about" : {}
}
}
}
'
分析
curl -XGET '192.168.0.227:9200/megacorp/employee/_search?pretty' -H 'Content-Type: application/json' -d'
{
"aggs": {
"all_interests": {
"terms": { "field": "interests" }
}
}
}
'
集群健康
curl -XGET 'http://192.168.0.227:9200/_cluster/health?pretty'
查看映射
curl -XGET 'http://192.168.0.227:9200/megacorp/_mapping/employee?pretty'
curl -XGET 'http://172.16.13.121:9200/product-info-index/_search?q=_id=0000000000000622'
curl -XGET 'http://172.19.26.16:9200/product-info-index/_search?q=_id=0000000000000703'
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于