esのquery_stringクエリ

  ESで要求を受け取った後、クエリパーサーはクエリ文字列を解析して、対応するクエリを作成します。

1.単一のフィールドクエリを指定する

  displayNameEnにジェームズまたはカレーが含まれています

  しかしまた使用し、

POST / nba / _search 
{ 
  "query":{ 
    "query_string":{ 
      "default_field": "displayNameEn"、
      "query": "james OR curry" 
    } 
  } 
}

  

2.クエリする複数のフィールドを指定する

  ここの順番は関係ありません

POST / nba / _search 
{ 
  "query":{ 
    "query_string":{ 
      "fields":[ 
        "displayNameEn"、 "teamNameEn" 
        ]、
      "query": "Rockets and james" 
    } 
  } 
}

  効果:

{ 
  "took":2、
  "timed_out":false、
  "_shards":{ 
    "total":1、
    "successful":1、
    " skiped ":0、
    "failed":0 
  }、
  "hits":{ 
    "total ":{ 
      " value ":5、
      " relation ":" eq " 
    }、
    " max_score ":4.699642、
    " hits ":[ 
      { 
        " _index ":" nba "、
        " _type ":" _doc "、
        " _id ": "214"、
        "_ score":4.699642、
        "_ source":{ 
          "countryEn": "アメリカ"、
          "teamName": "火矢印"、
          "birthDay":620107200000、
          "country": "美国"、
          "teamCityEn": "Houston"、
          "code": "james_harden"、
          "displayAffiliation": "Arizona State / United States"、
          "displayName": "詹ム斯哈登"、
          "schoolType": 「College」、
          「teamConference」:「西部」、
          「teamConferenceEn」:「Western」、
          「weight」:「99.8公斤」、
          「teamCity」:「休斯顿」、
          「playYear」:10、
          「jerseyNo」:「13」 、
          「teamNameEn」:「ロケット」、
          「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、
          「国」:「美国」、
          「teamCityEn」:「サクラメント」、
          「コード」:「justin_james」、
          「displayAffiliation」:「米国州」、
          "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" 
        } 
      }、
      { 
        "_index": "nba"、
        "_type ":" _doc "、
        "_id ":" 267 "、 
        " _score ":4.699642、
        " _source ":{ 
          " countryEn ":" United States "、
          " teamName ":"湖人 "、
          "birthDay":473230800000、 
          "country": "美国"、
          "teamCityEn": "ロサンゼルス"、
          "コード": "lebron_james"、
          "displayAffiliation": "カレッジ/アメリカなし"、
          "displayName": "ディレイ布朗詹哥斯"、
          "schoolType": " High School "、
          " teamConference ":"西部 "、
          " teamConferenceEn ":" Western "、
          " weight ":" 113.4公斤 "、
          " teamCity ":"洛杉矶 "、
          " playYear ":16、
          " jerseyNo ":" 23 " 、
          "teamNameEn": "レイカーズ、 
          「ドラフト」:2003、
          「displayNameEn」:「レブロンジェームス」、
          「heightValue」:2.03、
          「birthDayStr」:「1984-12-30」、 
          "position": "前锋"、
          "age":35、
          "playerId": "2544" 
        } 
      }、
      { 
        "_index": "nba"、
        "_type": "_doc"、
        "_id": "276"、
        "_score":4.699642、
        "_source":{ 
          "countryEn": 「United States」、
          「teamName」:「热火」、
          「birthDay」:540795600000、
          「country」:「美国」、
          「teamCityEn」:「マイアミ」、
          「コード」:「james_johnson」、
          「displayAffiliation」:「ウェイクフォレスト/アメリカ"、
          "displayName": "詹ι斯约哈逊"、
          "schoolType": "College"、 
          " teamConference ":"东部 "、
          "teamConferenceEn": "Eastern"、
          "weight": "108.9公斤"、
          "teamCity": "迈阿密"、
          "playYear":10、
          "jerseyNo": "16"、
          "teamNameEn": "Heat"、
          "draft":2009、
          "displayNameEn": "James Johnson"、
          "heightValue":2.03 、
          "birthDayStr": "1987-02-20"、
          "position": "前锋"、
          "age":32、
          "playerId": "201949" 
        } 
      }、
      { 
        "_index": "nba"、
        "_type": 「_doc」、「_ id」
        :"158"、 
        "_score":3.9148536、
        "_source":{  
          "countryEn": "米国"、
          "teamName": "76人"、
          "birthDay":646804800000、
          「country」:「美国」、
          「teamCityEn」:「フィラデルフィア」、
          「コード」:「james_ennis iii」、
          「displayAffiliation」:「Cal State-Long Beach / United States」、
          「displayName」:「詹ム斯恩尼斯三世」 、
          「schoolType」:「College」、
          「teamConference」:「东部」、
          「teamConferenceEn」:「東部」、
          「重量」:「95.3公斤」、
          「teamCity」:「费城」、
          「playYear」:5、
          「jerseyNo ":" 11 "、
          " teamNameEn ":"76ers "、 
          " draft ":2013、
          " displayNameEn ":" James Ennis III "、 
          " position ":"前锋 "、 
          " heightValue ":2.01、
          "birthDayStr": "1990年7月1日"、
          "年齢":29、
          "playerId": "203516" 
        } 
      } 
    ] 
  } 
}

  

おすすめ

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