• es之query_string查询


      ES中接到请求后,通过查询解析器,解析查询串⽣成对应的查询。

    1.指定单个字段查询

      displayNameEn包含james或者curry的

      也可是使用and

    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,
        "skipped" : 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" : "United States",
              "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" : "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" : "United States",
              "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"
            }
          },
          {
            "_index" : "nba",
            "_type" : "_doc",
            "_id" : "267",
            "_score" : 4.699642,
            "_source" : {
              "countryEn" : "United States",
              "teamName" : "湖人",
              "birthDay" : 473230800000,
              "country" : "美国",
              "teamCityEn" : "Los Angeles",
              "code" : "lebron_james",
              "displayAffiliation" : "No College/United States",
              "displayName" : "勒布朗 詹姆斯",
              "schoolType" : "High School",
              "teamConference" : "西部",
              "teamConferenceEn" : "Western",
              "weight" : "113.4 公斤",
              "teamCity" : "洛杉矶",
              "playYear" : 16,
              "jerseyNo" : "23",
              "teamNameEn" : "Lakers",
              "draft" : 2003,
              "displayNameEn" : "LeBron James",
              "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" : "Miami",
              "code" : "james_johnson",
              "displayAffiliation" : "Wake Forest/United States",
              "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" : "United States",
              "teamName" : "76人",
              "birthDay" : 646804800000,
              "country" : "美国",
              "teamCityEn" : "Philadelphia",
              "code" : "james_ennis iii",
              "displayAffiliation" : "Cal State-Long Beach/United States",
              "displayName" : "詹姆斯 恩尼斯三世",
              "schoolType" : "College",
              "teamConference" : "东部",
              "teamConferenceEn" : "Eastern",
              "weight" : "95.3 公斤",
              "teamCity" : "费城",
              "playYear" : 5,
              "jerseyNo" : "11",
              "teamNameEn" : "76ers",
              "draft" : 2013,
              "displayNameEn" : "James Ennis III",
              "heightValue" : 2.01,
              "birthDayStr" : "1990-07-01",
              "position" : "前锋",
              "age" : 29,
              "playerId" : "203516"
            }
          }
        ]
      }
    }
    

      

  • 相关阅读:
    ActionForm补充
    ActionForward
    struts模式匹配
    ActionMapping
    struts1.x的国际化
    DispatchAction
    ActionForm作为类型转换
    struts自定义异常
    hibernate核心接口
    Visual C# 2008+SQL Server 2005 数据库与网络开发 9.5 小结
  • 原文地址:https://www.cnblogs.com/juncaoit/p/12741841.html
Copyright © 2020-2023  润新知