uri search

# 根据code字段查
# http://$ip:9200/$index/_search?q=code:0052
GET /inventory2/_search?q=code:0052



# 多个index查找
GET /inventory1,inventory2/_search?q=code:0052

# 全部index查找
GET /_all/_search?q=tag:wow
浏览器查询
# http://$ip:9200/$index/_search?q=code:0052

 

https://www.elastic.co/guide/en/elasticsearch/reference/6.5/search-request-body.html#search-request-body

request body search


GET /inventory1/_search
{
    "query" : {
        "term" : { "code" : "0052" }
    }
}


GET /inventory1/_search
{
    "query" : {
        "match" : { "code" : "0052" }
    }
}


# from size 分页用
GET /inventory1,inventory2/_search
{
    "from":1,"size":2,
    "query" : {
        "term" : { "code" : "0052" }
    }
}

# highlight
GET /inventory1/_search
{
    "query" : {
        "match" : { "code" : "0052" }
    },
    "highlight" : {
        "fields" : {
            "code" : {}
        }
    }
}


# highlight 指定标签
GET /inventory1/_search
{
    "query" : {
        "match": { "code" : "0052" }
    },
    "highlight" : {
        "pre_tags" : ["<tag1>"],
        "post_tags" : ["</tag1>"],
        "fields" : {
            "code" : {}
        }
    }
}