首页 > 其他分享 >es练习

es练习

时间:2022-12-28 18:44:06浏览次数:30  
标签:search GET 练习 about student 101 class 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" : {}
        }
    }
}

  

标签:search,GET,练习,about,student,101,class,es
From: https://www.cnblogs.com/wenwenzuiniucha/p/17011015.html

相关文章