顿搜
飞过闲红千叶,夕岸在哪
类目归类
#根据_id查询文档详情
GET dbindex/_doc/文档_id查询指定索引库中所有的文档信息
GET dbindex/_doc/_search或者
GET /dbindex/_search
{
"query": { "match_all": {} }
}GET /dbindex/_search
{
"query": { "match_all": {} },
"sort":[
{"age":{"order":"desc"}}
]
}GET /dbindex/_search
{
"query": { "match_all": {} },
"_source":["name","age"],
"sort":[
{"age":{"order":"asc"}}
]
}GET /dbindex/_search
{
"query": { "match_all": {} },
"_source":["name","age"],
"sort":[
{"age":{"order":"asc"}}
],
"from":0,
"size":2
}GET /dbindex/_search
{
"query": {
"match":
{
"address": "中国,美国"
}
}
}使用match相当于包含GET /dbindex/_search
{
"query": {
"match":
{
"address": "中国 上海"
}
}
}因为查询的时候两个内容之间有空格,所以被当作分隔符处理,查询内容被分词
如果想要查询的内容不被分词,可使用match_phrase查询,
GET /dbindex/_search
{
"query": {
"match_phrase":
{
"address": "中国 上海"
}
}
}GET /dbindex/_doc/_search
{
"query": {
"term":
{
"address": "魏国"
}
}
}term也可用在text类型上,此时查询不分词,查询会匹配分词的结果
无意义)。无意义)。GET /dbindex/_search
{
"query": {
"bool" : {
"must" : {
"term" : { "username" : "张三" }
},
"filter": {
"term" : { "tags" : "production" }
},
"must_not" : {
"range" : {
"age" : { "gte" : 10, "lte" : 20 }
}
},
"should" : [
{ "term" : { "tags1" : "env1" } },
{ "term" : { "tags1" : "deployed" } }
],
"minimum_should_match" : 2, // 表示命中两个term文档才会被返回
"boost" : 1.0
}
}
}GET dbindex/_doc/_search
{
"query":{
"bool":{
"must":[
{
"match":{
"address":"杭州"
}
}
],
"filter":{
"range":{
"age":{
"gte":10,
"lte":20
}
}
}
}
}
}POST /dbindex/_doc/_search