常用curl来排查问题. 记录常用的几种用法.
##查看表结构
curl -XGET http://es-server:9200/_index/_type/_mapping?pretty
bool query
curl -XGET http://es-server:9200/_index/_type/_search?pretty -d '查询内容'
增加filter
在查询内容中 替换以下json, 支持多字段查询
{
"query":{
"bool":{
"must":[
{
"match":{
"biz":"pppAAA"
}
},
{
"match":{
"queryKey":"1233434"
}
}
]
}
}
}
match和term的区别是,match查询的时候,elasticsearch会根据你给定的字段提供合适的分析器,而term查询不会有分析器分析的过程 match查询相当于模糊匹配,只包含其中一部分关键词就行
增加range
{
"query":{
"bool":{
"must":[
{
"match":{
"biz":"pppAAA"
}
},
{
"match":{
"queryKey":"1233434"
}
}
],
"filter":{
"range":{
"operate_time":{
"gte":123,
"lte":33456,
"boost":1
}
}
}
}
}
}
增加sort
{
"query":{
"bool":{
"must":[
{
"match":{
"biz":"pppAAA"
}
},
{
"match":{
"queryKey":"1233434"
}
}
],
"filter":{
"range":{
"operate_time":{
"gte":123,
"lte":33456,
"boost":1
}
}
}
}
},
"size":50,
"from":0,
"fields":[
"id"
],
"sort":[
{
"expires":{
"order":"desc"
}
}
]
}