• es高亮查询


      如果返回的结果集中很多符合条件的结果,那怎么能⼀眼就能看到我们想要的那个结果呢?

    1.查询

      默认是em标签

    GET /nba_lastest/_search
    {
      "query": {
        "match": {
          "displayNameEn": "Adams"
        }
      },
      "highlight": {
        "fields": {
          "displayNameEn":{}
        }
      }
    }
    

      效果:

    {
      "took" : 178,
      "timed_out" : false,
      "_shards" : {
        "total" : 1,
        "successful" : 1,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : {
          "value" : 2,
          "relation" : "eq"
        },
        "max_score" : 5.6049123,
        "hits" : [
          {
            "_index" : "nba_20200202",
            "_type" : "_doc",
            "_id" : "2",
            "_score" : 5.6049123,
            "_source" : {
              "countryEn" : "New Zealand",
              "teamName" : "雷霆",
              "birthDay" : 743140800000,
              "country" : "新西兰",
              "teamCityEn" : "Oklahoma City",
              "code" : "steven_adams",
              "displayAffiliation" : "Pittsburgh/New Zealand",
              "displayName" : "斯蒂文 亚当斯",
              "schoolType" : "College",
              "teamConference" : "西部",
              "teamConferenceEn" : "Western",
              "weight" : "120.2 公斤",
              "teamCity" : "俄克拉荷马城",
              "playYear" : 6,
              "jerseyNo" : "12",
              "teamNameEn" : "Thunder",
              "draft" : 2013,
              "displayNameEn" : "Steven Adams",
              "heightValue" : 2.13,
              "birthDayStr" : "1993-07-20",
              "position" : "中锋",
              "age" : 26,
              "playerId" : "203500"
            },
            "highlight" : {
              "displayNameEn" : [
                "Steven <em>Adams</em>"
              ]
            }
          },
          {
            "_index" : "nba_20200202",
            "_type" : "_doc",
            "_id" : "1",
            "_score" : 5.6049123,
            "_source" : {
              "countryEn" : "United States",
              "teamName" : "老鹰",
              "birthDay" : 831182400000,
              "country" : "美国",
              "teamCityEn" : "Atlanta",
              "code" : "jaylen_adams",
              "displayAffiliation" : "United States",
              "displayName" : "杰伦 亚当斯",
              "schoolType" : "College",
              "teamConference" : "东部",
              "teamConferenceEn" : "Eastern",
              "weight" : "86.2 公斤",
              "teamCity" : "亚特兰大",
              "playYear" : 1,
              "jerseyNo" : "10",
              "teamNameEn" : "Hawks",
              "draft" : 2018,
              "displayNameEn" : "Jaylen Adams",
              "heightValue" : 1.88,
              "birthDayStr" : "1996-05-04",
              "position" : "后卫",
              "age" : 25,
              "playerId" : "1629121"
            },
            "highlight" : {
              "displayNameEn" : [
                "Jaylen <em>Adams</em>"
              ]
            }
          }
        ]
      }
    }
    

      

    2.自定义标签

    GET /nba_lastest/_search
    {
      "query": {
        "match": {
          "displayNameEn": "Adams"
        }
      },
      "highlight": {
        "fields": {
          "displayNameEn":{
            "pre_tags": ["<h1>"],
            "post_tags": ["</h1>"]
          }
        }
      }
    }
    

      效果:

    {
      "took" : 9,
      "timed_out" : false,
      "_shards" : {
        "total" : 1,
        "successful" : 1,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : {
          "value" : 2,
          "relation" : "eq"
        },
        "max_score" : 5.6049123,
        "hits" : [
          {
            "_index" : "nba_20200202",
            "_type" : "_doc",
            "_id" : "2",
            "_score" : 5.6049123,
            "_source" : {
              "countryEn" : "New Zealand",
              "teamName" : "雷霆",
              "birthDay" : 743140800000,
              "country" : "新西兰",
              "teamCityEn" : "Oklahoma City",
              "code" : "steven_adams",
              "displayAffiliation" : "Pittsburgh/New Zealand",
              "displayName" : "斯蒂文 亚当斯",
              "schoolType" : "College",
              "teamConference" : "西部",
              "teamConferenceEn" : "Western",
              "weight" : "120.2 公斤",
              "teamCity" : "俄克拉荷马城",
              "playYear" : 6,
              "jerseyNo" : "12",
              "teamNameEn" : "Thunder",
              "draft" : 2013,
              "displayNameEn" : "Steven Adams",
              "heightValue" : 2.13,
              "birthDayStr" : "1993-07-20",
              "position" : "中锋",
              "age" : 26,
              "playerId" : "203500"
            },
            "highlight" : {
              "displayNameEn" : [
                "Steven <h1>Adams</h1>"
              ]
            }
          },
          {
            "_index" : "nba_20200202",
            "_type" : "_doc",
            "_id" : "1",
            "_score" : 5.6049123,
            "_source" : {
              "countryEn" : "United States",
              "teamName" : "老鹰",
              "birthDay" : 831182400000,
              "country" : "美国",
              "teamCityEn" : "Atlanta",
              "code" : "jaylen_adams",
              "displayAffiliation" : "United States",
              "displayName" : "杰伦 亚当斯",
              "schoolType" : "College",
              "teamConference" : "东部",
              "teamConferenceEn" : "Eastern",
              "weight" : "86.2 公斤",
              "teamCity" : "亚特兰大",
              "playYear" : 1,
              "jerseyNo" : "10",
              "teamNameEn" : "Hawks",
              "draft" : 2018,
              "displayNameEn" : "Jaylen Adams",
              "heightValue" : 1.88,
              "birthDayStr" : "1996-05-04",
              "position" : "后卫",
              "age" : 25,
              "playerId" : "1629121"
            },
            "highlight" : {
              "displayNameEn" : [
                "Jaylen <h1>Adams</h1>"
              ]
            }
          }
        ]
      }
    }
    

      

  • 相关阅读:
    注释神器
    Q币直充-迅银渠道商(php 面向对象类)
    rsync 同步多台服务器项目目录
    wdcp 打开网页显示 Apache 2 Test Page powered by CentOS -- 来自辉哥博客
    elasticsearch批量修改,批量更新某个字段
    Ik分词器没有使用---------elasticsearch-analysis-ik 5.6.3分词问题
    spring-boot-starter-data-elasticsearch 整合elasticsearch 5.x详解
    FastJson--SerializerFeature.PrettyFormat 如何实现格式化源码查看
    由Premature end of Content-Length delimited message body因发的问题排查
    JVM的YoungGC日志查看
  • 原文地址:https://www.cnblogs.com/juncaoit/p/12815609.html
Copyright © 2020-2023  润新知