es练习

PUT /student

PUT /student/_doc/1
{
    "name" :  "张三",
    "class" :   "101",
    "age" :         10,
    "about" :       "I like to collect rock albums",
    "tags":  [ "乒乓球","羽毛球" ]
}

PUT /student/_doc/2
{
    "name" :  "李四",
    "class" :   "101",
    "age" :         12,
    "about" :       "我是李四",
    "tags":  [ "篮球","羽毛球" ]
}

PUT /student/_doc/3
{
    "name" :  "王五",
    "class" :   "102",
    "age" :         13,
    "about" :       "俺是王五",
    "tags":  [ "足球","篮球" ]
}

PUT /student/_doc/4
{
    "name" :  "孙六",
    "class" :   "101",
    "age" :         14,
    "about" :       "俺是孙六",
    "tags":  [ "乒乓","篮球" ]
}


get /student/_doc/1

GET /student/_search

GET /student/_search
{
    "query" : {
        "match" : {
            "class" : "101"
        }
    }
}

GET /student/_search
{
    "query" : {
        "bool": {
            "must": {
                "match" : {
                    "class" : "101" 
                }
            },
            "filter": {
                "range" : {
                    "age" : { "gt" : 11 } 
                }
            }
        }
    }
}

GET /student/_search
{
    "query" : {
        "match" : {
            "about" : "俺是"
        }
    }
}

GET /student/_search
{
    "query" : {
        "match_phrase" : {
            "about" : "俺是"
        }
    },
    "highlight": {
        "fields" : {
            "about" : {}
        }
    }
}

  

posted @ 2022-12-28 18:38  傲云萧雨  阅读(21)  评论(0编辑  收藏  举报