elasticsearch search api

 

uri search

# 根據code字段查
GET /inventory2/_search?q=code:0052

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

# 全部index查找
GET /_all/_search?q=tag:wow

 

 

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" : {}
        }
    }
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章