esのブールクエリ

1.説明

  

 

 

2.必須(ワシントンとの名前がdisplayAffiliationであるプレーヤーを見つける)

POST / nba / _search 
{ 
  "query":{ 
    "bool":{ 
      "must":[ 
        { 
          "match":{ 
            "displayAffiliation": "Washington" 
          } 
        } 
      ] 
    } 
  } 
}

  

3.フィルター

  必要と同じ効果がありますが、得点はありません

 

4.must_not

POST / nba / _search 
{ 
  "query":{ 
    "bool":{ 
      "must_not":[ 
        { 
          "match":{ 
            "displayAffiliation": "Washington" 
          } 
        } 
      ] 
    } 
  } 
}

  

4.すべきである(名前がJamesであるプレーヤーを探して、11〜20歳である必要があります)

  いくつかの問題があるはずであることがわかった、いくつかは望まれていない。

POST / nba / _search 
{ 
    "query":{ 
        "bool":{ 
            "must":[{ 
                    "match":{ 
                        "displayNameEn": "james" 
                    } 
                } 
            ]、
            "must_not":[{ 
                "term":{ 
                    " teamConferenceEn ":{ 
                        " value ":" Eastern " 
                    } 
                } 
            }]、
            " should ":[{ 
                " range ":{ 
                    " playYear ":{ 
                        "gte":11、 
                        "lte":20
                    }
                } 
            }] 
        } 
    } 
}

  効果:

{ 
  "took":1、
  "timed_out":false、
  "_shards":{ 
    "total":1、
    "successful":1、
    " skiped ":0、
    "failed":0 
  }、
  "hits":{ 
    "total ":{ 
      " value ":3、
      " relation ":" eq " 
    }、
    " max_score ":5.699642、
    " hits ":[ 
      { 
        " _index ":" nba "、
        " _type ":" _doc "、
        " _id ": "267"、
        "_ score":5.699642、
        "_ source":{ 
          "countryEn": "アメリカ"、
          "teamName": "湖人"、
          "birthDay":473230800000、 
          "country": "美国"、
          「teamCityEn」:「ロサンゼルス」、
          「コード」:「lebron_james」、
          「displayAffiliation」:「大学/米国なし」、
          「displayName」:「レル布朗詹迪斯」、
          「schoolType」:「高校」、
          「teamConference ":"西部 "、
          " teamConferenceEn ":" Western "、
          " weight ":" 113.4公斤 "、
          " teamCity ":"洛杉矶 "、
          " playYear ":16、
          " jerseyNo ":" 23 "、
          " teamNameEn ":"レイカーズ」、
          「ドラフト」:2003、
          "displayNameEn": "LeBron James"、
          "heightValue":2.03、
          「birthDayStr」:「1984-12-30」、
          "position": "前锋"、 
          "age":35、 
          "playerId": "2544" 
        } 
      }、
      { 
        "_index": "nba"、
        "_type": "_doc"、
        "_id": "214"、
        "_score":4.699642、
        " _source ":{ 
          " countryEn ":" United States "、
          " teamName ":"火矢印 "、
          " birthDay ":620107200000、
          " country ":"美国 "、
          " teamCityEn ":" Houston "、
          " code ":" james_harden " 、
          「displayAffiliation ":"アリゾナ州/アメリカ合衆国 "、 
          " displayName ":"詹ι斯哈登 "、
          " schoolType ":" College "、
          " teamConference ":"西部 "、
          "teamConferenceEn": "Western"、 
          「weight」:「99.8公斤」、
          "teamCity": "休斯顿"、
          "playYear":10、
          "jerseyNo": "13"、
          "teamNameEn": "Rockets"、
          "draft":2009、
          "displayNameEn": "James Harden "、
          " heightValue ":1.96、
          " birthDayStr ":" 1989-08-26 "、
          " position ":"后卫 "、
          " age ":30、
          " playerId ":" 201935 " 
        } 
      }、
      { 
        " _index ": "nba"、
        "_type": "_doc"、
        "_id": "266"、
        "_score":4.699642、
        "_source":{ 
          "countryEn": "米国"、
          "teamName": "国王"、 
          "birthDay":854082000000、
          "country": "美国"、
          "teamCityEn": "Sacramento"、
          "code": "justin_james"、
          "displayAffiliation": "United States"、
          "displayName": "贾斯斯詹詹斯斯"、
          "schoolType": "College"、
          "teamConference": "西部"、
          "teamConferenceEn": "Western"、
          "weight": "86.2公斤"、
          "teamCity": "萨克拉门托"、
          "playYear":0、
          "jerseyNo" :「」、
          "teamNameEn": "Kings"、
          "draft":2019、
          "displayNameEn": "Justin James"、
          "heightValue":2.01、
          "birthDayStr": "1997-01-24"、 
          「position」:「后卫-前锋」、
          「age」:22、
          "playerId": "1629713" 
        } 
      } 
    ] 
  } 
}

  

5.精度を向上させる

  "minimum_should_match":1は、少なくとも1つの条件を満たす必要があることを意味します

POST / nba / _search 
{ 
    "query":{ 
        "bool":{ 
            "must":[{ 
                    "match":{ 
                        "displayNameEn": "james" 
                    } 
                } 
            ]、
            "must_not":[{ 
                "term":{ 
                    " teamConferenceEn ":{ 
                        " value ":" Eastern " 
                    } 
                } 
            }]、
            " should ":[{ 
                " range ":{ 
                    " playYear ":{ 
                        "gte":11、 
                        "lte":20
                    }
                } 
            }]、
            "minimum_should_match":1 
        } 
    } 
}

  効果:

{ 
  "took":11、
  "timed_out":false、
  "_shards":{ 
    "total":1、
    "successful":1、
    "skipped":0、
    "failed":0 
  }、
  "hits":{ 
    "total ":{ 
      " value ":1、
      " relation ":" eq " 
    }、
    " max_score ":5.699642、
    " hits ":[ 
      { 
        " _index ":" nba "、
        " _type ":" _doc "、
        " _id ": "267"、
        "_ score":5.699642、
        "_ source":{ 
          "countryEn": "アメリカ"、
          "teamName": "湖人"、
          "birthDay":473230800000、 
          "country": "美国"、 
          "teamCityEn": "ロサンゼルス"、
          "code": "lebron_james"、
          "displayAffiliation": "カレッジ/アメリカなし"、
          "displayName": "LER布朗詹哥斯"、
          "schoolType" :「高校」、
          「teamConference」:「西部」、
          「teamConferenceEn」:「西部」、
          「重量」:「113.4公斤」、
          「teamCity」:「洛杉矶」、
          「playYear」:16、
          「jerseyNo」:「 23 "、
          " teamNameEn ":"レイカーズ、 
          「ドラフト」:2003、
          「displayNameEn」:「レブロンジェームス」、
          「heightValue」:2.03、
          「birthDayStr」:「1984-12-30」、
          "position": "前锋"、 
          "age":35、
          "playerId": "2544" 
        } 
      } 
    ] 
  } 
}

  

 

おすすめ

転載: www.cnblogs.com/juncaoit/p/12717026.html