1. 程式人生 > 實用技巧 >ES基礎(二十) 單字串多欄位查詢:Dis Max Query

ES基礎(二十) 單字串多欄位查詢:Dis Max Query

PUT /blogs/_doc/1
{
    "title": "Quick brown rabbits",
    "body":  "Brown rabbits are commonly seen."
}

PUT /blogs/_doc/2
{
    "title": "Keeping pets healthy",
    "body":  "My quick brown fox eats rabbits on a regular basis."
}

POST /blogs/_search
{
    "query": {
        "bool": {
            
"should": [ { "match": { "title": "Brown fox" }}, { "match": { "body": "Brown fox" }} ] } } } POST blogs/_search { "query": { "dis_max": { "queries": [ { "match": { "title": "Quick pets" }}, {
"match": { "body": "Quick pets" }} ] } } } POST blogs/_search { "query": { "dis_max": { "queries": [ { "match": { "title": "Quick pets" }}, { "match": { "body": "Quick pets" }} ], "tie_breaker": 0.2 } } }