Domain Specific Language
特定领域语言,基于JSON格式的数据查询,查询更灵活,有利于复杂查询
一、普通url路径参数搜索
  • 数据准备
1.建立名字为 shop 的索引
2.手动建立mappings

  1. POST http://192.168.2.223:9200/shop/_mapping
  2. {
  3. "properties": {
  4. "id": {
  5. "type": "long"
  6. },
  7. "age": {
  8. "type": "integer"
  9. },
  10. "username": {
  11. "type": "keyword"
  12. },
  13. "nickname": {
  14. "type": "text",
  15. "analyzer": "ik_max_word"
  16. },
  17. "money": {
  18. "type": "float"
  19. },
  20. "desc": {
  21. "type": "text",
  22. "analyzer": "ik_max_word"
  23. },
  24. "sex": {
  25. "type": "byte"
  26. },
  27. "birthday": {
  28. "type": "date"
  29. },
  30. "face": {
  31. "type": "text",
  32. "index": false
  33. }
  34. }
  35. }
3.添加数据

  1. POST http://192.168.2.223:9200/shop/_doc/1001
  2. {
  3. "id": 1011,
  4. "age": 31,
  5. "username": "sprder",
  6. "nickname": "皮特帕克",
  7. "money": 180.8,
  8. "desc": "它是一个超级英雄",
  9. "sex": 1,
  10. "birthday": "1989-08-14",
  11. "face": "https://www.zhouhong.com/static/img/index/logo.png"
  12. }
  13. {
  14. "id": 1008,
  15. "age": 19,
  16. "username": "zhoujiang",
  17. "nickname": "周江",
  18. "money": 1056.8,
  19. "desc": "周江大学毕业后,进了阿里",
  20. "sex": 1,
  21. "birthday": "1995-06-14",
  22. "face": "https://www.zhouhong.com/static/img/index/logo.png"
  23. }
  24. {
  25. "id": 1007,
  26. "age": 19,
  27. "username": "msgame",
  28. "nickname": "gamexbox",
  29. "money": 1056.8,
  30. "desc": "明天去进货,最近微软处理很多游戏机,还要买xbox游戏卡带",
  31. "sex": 1,
  32. "birthday": "1985-05-14",
  33. "face": "https://www.zhouhong.com/static/img/index/logo.png"
  34. }
  35. {
  36. "id": 1003,
  37. "age": 20,
  38. "username": "bigFace",
  39. "nickname": "飞翔的巨鹰",
  40. "money": 66.8,
  41. "desc": "周江和导游坐飞机去海外旅游,去了新马泰和欧洲",
  42. "sex": 1,
  43. "birthday": "1996-01-14",
  44. "face": "https://www.zhouhong.com/static/img/index/logo.png"
  45. }
  46. {
  47. "id": 1002,
  48. "age": 19,
  49. "username": "zhouhong",
  50. "nickname": "周红",
  51. "money": 77.8,
  52. "desc": "今天上下班都很堵,车流量很大",
  53. "sex": 1,
  54. "birthday": "1993-01-24",
  55. "face": "https://www.zhouhong.com/static/img/index/logo.png"
  56. }
  57. {
  58. "id": 1012,
  59. "age": 31,
  60. "username": "super hero",
  61. "nickname": "super hero",
  62. "money": 188.8,
  63. "desc": "BatMan, GreenArrow, SpiderMan, IronMan... are all Super Hero",
  64. "sex": 1,
  65. "birthday": "1980-08-14",
  66. "face": "https://www.zhouhong.com/static/img/index/logo.png"
  67. }
  68. {
  69. "id": 1010,
  70. "age": 30,
  71. "username": "tata",
  72. "nickname": "隔壁老王",
  73. "money": 100.8,
  74. "desc": "隔壁老外去国外出差,带给我很多好吃的",
  75. "sex": 1,
  76. "birthday": "1988-07-14",
  77. "face": "https://www.zhouhong.com/static/img/index/logo.png"
  78. }
  79. {
  80. "id": 1009,
  81. "age": 22,
  82. "username": "shaonian",
  83. "nickname": "骚年轮",
  84. "money": 96.8,
  85. "desc": "骚年在大学毕业后,考研究生去了",
  86. "sex": 1,
  87. "birthday": "1998-07-14",
  88. "face": "https://www.zhouhong.com/static/img/index/logo.png"
  89. }
  90. {
  91. "id": 1006,
  92. "age": 19,
  93. "username": "zhouhong",
  94. "nickname": "我叫周红",
  95. "money": 156.8,
  96. "desc": "我叫周红,今年20岁,是一名毕业生,我在琦䯲星球做演讲",
  97. "sex": 1,
  98. "birthday": "1993-04-14",
  99. "face": "https://www.zhouhong.com/static/img/index/logo.png"
  100. }
  101. {
  102. "id": 1005,
  103. "age": 25,
  104. "username": "gotoplay",
  105. "nickname": "ps游戏机",
  106. "money": 155.8,
  107. "desc": "今年生日,女友送了我一台play station游戏机,非常好玩,非常不错",
  108. "sex": 1,
  109. "birthday": "1989-03-14",
  110. "face": "https://www.zhouhong.com/static/img/index/logo.png"
  111. }
  112. {
  113. "id": 1004,
  114. "age": 22,
  115. "username": "flyfish",
  116. "nickname": "水中鱼",
  117. "money": 55.8,
  118. "desc": "昨天周红在学校的池塘里,看到有很多鱼在游泳",
  119. "sex": 0,
  120. "birthday": "1988-02-14",
  121. "face": "https://www.zhouhong.com/static/img/index/logo.png"
  122. }
  123. {
  124. "id": 1001,
  125. "age": 18,
  126. "username": "zhoujiang",
  127. "nickname": "周江",
  128. "money": 88.8,
  129. "desc": "周江在大学学习java和前端",
  130. "sex": 0,
  131. "birthday": "1992-12-24",
  132. "face": "https://www.zhouhong.com/static/img/index/logo.png"
  133. }
二、检索:
普通检索:
  • http://192.168.2.223:9200/shop/_search?q=desc:周红&q=age:20
    1. {
    2. "took": 8,
    3. "timed_out": false,
    4. "_shards": {
    5. "total": 3,
    6. "successful": 3,
    7. "skipped": 0,
    8. "failed": 0
    9. },
    10. "hits": {
    11. "total": {
    12. "value": 1,
    13. "relation": "eq"
    14. },
    15. "max_score": 1,
    16. "hits": [
    17. {
    18. "_index": "shop",
    19. "_type": "_doc",
    20. "_id": "1003",
    21. "_score": 1,
    22. "_source": {
    23. "id": 1003,
    24. "age": 20,
    25. "username": "bigFace",
    26. "nickname": "飞翔的巨鹰",
    27. "money": 66.8,
    28. "desc": "周江和导游坐飞机去海外旅游,去了新马泰和欧洲",
    29. "sex": 1,
    30. "birthday": "1996-01-14",
    31. "face": "https://www.zhouhong.com/static/img/index/logo.png"
    32. }
    33. }
    34. ]
    35. }
    36. }
DSL检索:
  • match_phrase 查询同一个字段中几个词,可以跳过其他词,slop表示可以跳过的最大词数
    • POST http://192.168.2.223:9200/shop/_doc/_search operator 为 “or”表示:字段只要有一个分词就可以查出来,operator 为 “and”表示:字段必须包含分词分出来的所有字段。
      1. {
      2. "query": {
      3. "match": {
      4. "desc": {
      5. "query": "周红",
      6. "operator": "and"
      7. }
      8. }
      9. },
      10. "_source": ["id","username","age"]
      11. }
    • POST http://192.168.2.223:9200/shop/_doc/_search
    • ​minimum_should_match: 最低匹配精度,至少有[分词后的词语个数]x百分百,得出一个数据值取整。举个例子:当前属性设置为70,若一个用户查询检索内容分词后有10个词语,那么匹配度按照 10x70%=7,则desc中至少需要有7个词语匹配,就展示;若分词后有8个,则 8x70%=5.6,则desc中至少需要有5个词语匹配,就展示。
    • minimum_should_match 也能设置具体的数字,表示拆分出来的词在一个字段中个数
      1. {
      2. "query": {
      3. "match": {
      4. "desc": {
      5. "query": "女友生日送我好玩的xbox游戏机",
      6. "minimum_should_match": "60%"
      7. }
      8. }
      9. }
      10. }
  • multi_match 对多个字段进行检索
    • POST http://192.168.2.223:9200/shop/_doc/_search ^10 表示权重,权重,为某个字段设置权重,权重越高,文档相关性得分就越高。通畅来说搜索商品名称要比商品简介的权重更高。
      1. {
      2. "query": {
      3. "multi_match": {
      4. "query": "游戏",
      5. "fields": [
      6. "desc^10","nickname"
      7. ]
      8. }
      9. }
      10. }
  • bool 查询
    • POST http://192.168.2.223:9200/shop/_doc/_search
    • must :多个条件全部要满足, should:或者的意思,满足一个条件即可,must_not :除了满足所有条件剩下的数据。
      1. {
      2. "query": {
      3. "bool": {
      4. "must": [
      5. {
      6. "multi_match": {
      7. "query": "游戏",
      8. "fields": ["desc","nickname"]
      9. }
      10. },
      11. {
      12. "term": {
      13. "age": "19"
      14. }
      15. }
      16. ]
      17. }
      18. }
      19. }
  • post_filter 过滤器
    • POST http://192.168.2.223:9200/shop/_doc/_search
    • 对搜索出来的结果进行数据过滤。不会到es库里去搜,不会去计算文档的相关度分数,所以过滤的性能会比较高,过滤器可以和全文搜索结合在一起使用。
post_filter元素是一个顶层元素,只会对搜索结果进行过滤。不会计算数据的匹配度相关性分数,不会根据分数去排序,query则相反,会计算分数,也会按照分数去排序。
使用场景:
  • ​query:根据用户搜索条件检索匹配记录
  • post_filter:用于查询后,对结果数据的筛选
实操:查询账户金额大于80元,小于等于155.8元的用户
gte:大于等于
lte:小于等于
gt:大于
lt:小于
  1. {
  2. "query": {
  3. "match": {
  4. "sex": "1"
  5. }
  6. },
  7. "post_filter": {
  8. "range": {
  9. "money": {
  10. "gte": 60,
  11. "lte": 155.8
  12. }
  13. }
  14. }
  15. }
  • sort 排序功能
    • POST http://192.168.2.223:9200/shop/_doc/_search 先以money排序再以age排序,注意:只能对整形排序,不能对文本类型排序。
      1. {
      2. "query": {
      3. "match": {
      4. "sex": "1"
      5. }
      6. },
      7. "sort": [
      8. {
      9. "money": "asc"
      10. },
      11. {
      12. "age": "asc"
      13. }
      14. ]
      15. }
    • 对文本排序
    • 需要对排序字段加一个附加属性,类型选择为keyword
      1. 1.创建索引
      2. POST /shop2/_mapping
      3. {
      4. "properties": {
      5. "id": {
      6. "type": "long"
      7. },
      8. "nickname": {
      9. "type": "text",
      10. "analyzer": "ik_max_word",
      11. "fields": {
      12. "keyword": {
      13. "type": "keyword"
      14. }
      15. }
      16. }
      17. }
      18. }

      1. 2.插入数据
      2. POST /shop2/_doc
      3. {
      4. "id": 1001,
      5. "nickname": "美丽的风景"
      6. }
      7. {
      8. "id": 1002,
      9. "nickname": "漂亮的小哥哥"
      10. }
      11. {
      12. "id": 1003,
      13. "nickname": "飞翔的巨鹰"
      14. }
      15. {
      16. "id": 1004,
      17. "nickname": "完美的天空"
      18. }
      19. {
      20. "id": 1005,
      21. "nickname": "广阔的海域"
      22. }
      1. 3.排序 POST http://192.168.2.223:9200/shop2/_doc/_search
      2. {
      3. "sort": [
      4. {
      5. "nickname.keyword": "desc"
      6. }
      7. ]
      8. }
  • highlight 关键字高亮显示
    • POST http://192.168.2.223:9200/shop/_doc/_search
      1. {
      2. "query": {
      3. "match": {
      4. "desc": "周红"
      5. }
      6. },
      7. "highlight": {
      8. "pre_tags": ["<span>"],
      9. "post_tags": ["</span>"],
      10. "fields": {
      11. "desc": {}
      12. }
      13. }
      14. }
      结果:默认为em标签,上面设置为自定义的<span>标签,对页面 em/span 标签做一个颜色设置就可以实现高亮显示了。
      1. {
      2. "took": 110,
      3. "timed_out": false,
      4. "_shards": {
      5. "total": 3,
      6. "successful": 3,
      7. "skipped": 0,
      8. "failed": 0
      9. },
      10. "hits": {
      11. "total": {
      12. "value": 2,
      13. "relation": "eq"
      14. },
      15. "max_score": 1.1329247,
      16. "hits": [
      17. {
      18. "_index": "shop",
      19. "_type": "_doc",
      20. "_id": "1004",
      21. "_score": 1.1329247,
      22. "_source": {
      23. "id": 1004,
      24. "age": 22,
      25. "username": "flyfish",
      26. "nickname": "水中鱼",
      27. "money": 55.8,
      28. "desc": "昨天周红在学校的池塘里,看到有很多鱼在游泳",
      29. "sex": 0,
      30. "birthday": "1988-02-14",
      31. "face": "https://www.zhouhong.com/static/img/index/logo.png"
      32. },
      33. "highlight": {
      34. "desc": [
      35. "昨天<em>周红</em>在学校的池塘里,看到有很多鱼在游泳"
      36. ]
      37. }
      38. },
      39. {
      40. "_index": "shop",
      41. "_type": "_doc",
      42. "_id": "1006",
      43. "_score": 0.9585575,
      44. "_source": {
      45. "id": 1006,
      46. "age": 19,
      47. "username": "zhouhong",
      48. "nickname": "我叫周红",
      49. "money": 156.8,
      50. "desc": "我叫周红,今年20岁,是一名毕业生,我在琦䯲星球做演讲",
      51. "sex": 1,
      52. "birthday": "1993-04-14",
      53. "face": "https://www.zhouhong.com/static/img/index/logo.png"
      54. },
      55. "highlight": {
      56. "desc": [
      57. "我叫<em>周红</em>,今年20岁,是一名毕业生,我在琦䯲星球做演讲"
      58. ]
      59. }
      60. }
      61. ]
      62. }
Domain Specific Language
特定领域语言,基于JSON格式的数据查询,查询更灵活,有利于复杂查询
一、普通url路径参数搜索
  • 数据准备
1.建立名字为 shop 的索引
2.手动建立mappings
POST http://192.168.2.223:9200/shop/_mapping
{
"properties": {
"id": {
"type": "long"
},
"age": {
"type": "integer"
},
"username": {
"type": "keyword"
},
"nickname": {
"type": "text",
"analyzer": "ik_max_word"
},
"money": {
"type": "float"
},
"desc": {
"type": "text",
"analyzer": "ik_max_word"
},
"sex": {
"type": "byte"
},
"birthday": {
"type": "date"
},
"face": {
"type": "text",
"index": false
}
}
}

3.添加数据
POST http://192.168.2.223:9200/shop/_doc/1001
{
"id": 1011,
"age": 31,
"username": "sprder",
"nickname": "皮特帕克",
"money": 180.8,
"desc": "它是一个超级英雄",
"sex": 1,
"birthday": "1989-08-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1008,
"age": 19,
"username": "zhoujiang",
"nickname": "周江",
"money": 1056.8,
"desc": "周江大学毕业后,进了阿里",
"sex": 1,
"birthday": "1995-06-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1007,
"age": 19,
"username": "msgame",
"nickname": "gamexbox",
"money": 1056.8,
"desc": "明天去进货,最近微软处理很多游戏机,还要买xbox游戏卡带",
"sex": 1,
"birthday": "1985-05-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1003,
"age": 20,
"username": "bigFace",
"nickname": "飞翔的巨鹰",
"money": 66.8,
"desc": "周江和导游坐飞机去海外旅游,去了新马泰和欧洲",
"sex": 1,
"birthday": "1996-01-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1002,
"age": 19,
"username": "zhouhong",
"nickname": "周红",
"money": 77.8,
"desc": "今天上下班都很堵,车流量很大",
"sex": 1,
"birthday": "1993-01-24",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1012,
"age": 31,
"username": "super hero",
"nickname": "super hero",
"money": 188.8,
"desc": "BatMan, GreenArrow, SpiderMan, IronMan... are all Super Hero",
"sex": 1,
"birthday": "1980-08-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1010,
"age": 30,
"username": "tata",
"nickname": "隔壁老王",
"money": 100.8,
"desc": "隔壁老外去国外出差,带给我很多好吃的",
"sex": 1,
"birthday": "1988-07-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1009,
"age": 22,
"username": "shaonian",
"nickname": "骚年轮",
"money": 96.8,
"desc": "骚年在大学毕业后,考研究生去了",
"sex": 1,
"birthday": "1998-07-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1006,
"age": 19,
"username": "zhouhong",
"nickname": "我叫周红",
"money": 156.8,
"desc": "我叫周红,今年20岁,是一名毕业生,我在琦䯲星球做演讲",
"sex": 1,
"birthday": "1993-04-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1005,
"age": 25,
"username": "gotoplay",
"nickname": "ps游戏机",
"money": 155.8,
"desc": "今年生日,女友送了我一台play station游戏机,非常好玩,非常不错",
"sex": 1,
"birthday": "1989-03-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1004,
"age": 22,
"username": "flyfish",
"nickname": "水中鱼",
"money": 55.8,
"desc": "昨天周红在学校的池塘里,看到有很多鱼在游泳",
"sex": 0,
"birthday": "1988-02-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1001,
"age": 18,
"username": "zhoujiang",
"nickname": "周江",
"money": 88.8,
"desc": "周江在大学学习java和前端",
"sex": 0,
"birthday": "1992-12-24",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
二、检索:
  • http://192.168.2.223:9200/shop/_search?q=desc:周红&q=age:20
{
"took": 8,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "shop",
"_type": "_doc",
"_id": "1003",
"_score": 1,
"_source": {
"id": 1003,
"age": 20,
"username": "bigFace",
"nickname": "飞翔的巨鹰",
"money": 66.8,
"desc": "周江和导游坐飞机去海外旅游,去了新马泰和欧洲",
"sex": 1,
"birthday": "1996-01-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
}
]
}
}
 
二、DSL搜索
{
"query": {
"match_all": {}
}
}
{
"query": {
"match_all": {}
},
"_source": ["id","username","age"]
}
{
"query": {
"match_all": {}
},
"_source": ["id","username","age"],
"from": 0,
"size": 5
}
{
"query": {
"match_phrase": {
"desc": {
"query": "今天 车流量",
"slop": 100
}
}
}
}
{
"query": {
"term": {
"desc": "学习"
}
}
}
  • terms 对个关键字查询
{
"query": {
"terms": {
"desc": ["学习","周红","周江"]
}
}
}
{
"query": {
"match": {
"desc": "周红"
}
},
"_source": ["id","username","age"]
}
{
"query": {
"match": {
"desc": {
"query": "周红",
"operator": "and"
}
}
},
"_source": ["id","username","age"]
}
    • POST http://192.168.2.223:9200/shop/_doc/_search
    • ​minimum_should_match: 最低匹配精度,至少有[分词后的词语个数]x百分百,得出一个数据值取整。举个例子:当前属性设置为70,若一个用户查询检索内容分词后有10个词语,那么匹配度按照 10x70%=7,则desc中至少需要有7个词语匹配,就展示;若分词后有8个,则 8x70%=5.6,则desc中至少需要有5个词语匹配,就展示。
    • minimum_should_match 也能设置具体的数字,表示拆分出来的词在一个字段中个数
{
"query": {
"match": {
"desc": {
"query": "女友生日送我好玩的xbox游戏机",
"minimum_should_match": "60%"
}
}
}
}
{
"query": {
"ids": {
"type": "_doc",
"values": ["1001","1005","1006"]
}
},
"_source": ["id","username","desc"]
}
  • multi_match 对多个字段进行检索
    • POST http://192.168.2.223:9200/shop/_doc/_search ^10 表示权重,权重,为某个字段设置权重,权重越高,文档相关性得分就越高。通畅来说搜索商品名称要比商品简介的权重更高。
{
"query": {
"multi_match": {
"query": "游戏",
"fields": [
"desc^10","nickname"
]
}
}
}
{
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "游戏",
"fields": ["desc","nickname"]
}
},
{
"term": {
"age": "19"
}
}
]
}
}
}
 
  • post_filter 过滤器
    • POST http://192.168.2.223:9200/shop/_doc/_search
    • 对搜索出来的结果进行数据过滤。不会到es库里去搜,不会去计算文档的相关度分数,所以过滤的性能会比较高,过滤器可以和全文搜索结合在一起使用。
post_filter元素是一个顶层元素,只会对搜索结果进行过滤。不会计算数据的匹配度相关性分数,不会根据分数去排序,query则相反,会计算分数,也会按照分数去排序。
使用场景:
  • ​query:根据用户搜索条件检索匹配记录
  • post_filter:用于查询后,对结果数据的筛选
实操:查询账户金额大于80元,小于等于155.8元的用户
gte:大于等于
lte:小于等于
gt:大于
lt:小于
{
"query": {
"match": {
"sex": "1"
}
},
"post_filter": {
"range": {
"money": {
"gte": 60,
"lte": 155.8
}
}
}
}
 
{
"query": {
"match": {
"sex": "1"
}
},
"sort": [
{
"money": "asc"
},
{
"age": "asc"
}
]
}
    • 对文本排序
    • 需要对排序字段加一个附加属性,类型选择为keyword
1.创建索引
POST /shop2/_mapping
{
"properties": {
"id": {
"type": "long"
},
"nickname": {
"type": "text",
"analyzer": "ik_max_word",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
 
2.插入数据
POST /shop2/_doc
{
"id": 1001,
"nickname": "美丽的风景"
}
{
"id": 1002,
"nickname": "漂亮的小哥哥"
}
{
"id": 1003,
"nickname": "飞翔的巨鹰"
}
{
"id": 1004,
"nickname": "完美的天空"
}
{
"id": 1005,
"nickname": "广阔的海域"
}

 
3.排序 POST http://192.168.2.223:9200/shop2/_doc/_search
{
"sort": [
{
"nickname.keyword": "desc"
}
]
}

{
"query": {
"exists": {
"field": "desc"
}
}
}
 
{
"query": {
"match": {
"desc": "周红"
}
},
"highlight": {
"pre_tags": ["<span>"],
"post_tags": ["</span>"],
"fields": {
"desc": {}
}
}
}
结果:默认为em标签,上面设置为自定义的<span>标签,对页面 em/span 标签做一个颜色设置就可以实现高亮显示了。
{
"took": 110,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1.1329247,
"hits": [
{
"_index": "shop",
"_type": "_doc",
"_id": "1004",
"_score": 1.1329247,
"_source": {
"id": 1004,
"age": 22,
"username": "flyfish",
"nickname": "水中鱼",
"money": 55.8,
"desc": "昨天周红在学校的池塘里,看到有很多鱼在游泳",
"sex": 0,
"birthday": "1988-02-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
},
"highlight": {
"desc": [
"昨天<em>周红</em>在学校的池塘里,看到有很多鱼在游泳"
]
}
},
{
"_index": "shop",
"_type": "_doc",
"_id": "1006",
"_score": 0.9585575,
"_source": {
"id": 1006,
"age": 19,
"username": "zhouhong",
"nickname": "我叫周红",
"money": 156.8,
"desc": "我叫周红,今年20岁,是一名毕业生,我在琦䯲星球做演讲",
"sex": 1,
"birthday": "1993-04-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
},
"highlight": {
"desc": [
"我叫<em>周红</em>,今年20岁,是一名毕业生,我在琦䯲星球做演讲"
]
}
}
]
}
}
 

Elasticsearch---DSL搜索实践的更多相关文章

  1. Elasticsearch(ES)的高级搜索(DSL搜索)(上篇)

    1. 概述 之前聊了一下 Elasticsearch(ES)的基本使用,今天我们聊聊 Elasticsearch(ES)的高级搜索(DSL搜索),由于DSL搜索内容比较多,因此分为两篇文章完成. 2. ...

  2. Elasticsearch(ES)的高级搜索(DSL搜索)(下篇)

    1. 概述 之前聊了Elasticsearch(ES)的高级搜索(DSL搜索)的一部分内容,今天把剩下的部分聊完. 2. 场景说明 2.1 创建索引同时创建映射 PUT  http://192.168 ...

  3. ElasticSearch位置搜索

    ElasticSearch位置搜索 学习了:https://blog.csdn.net/bingduanlbd/article/details/52253542 学习了:https://blog.cs ...

  4. ElasticSearch入门-搜索(java api)

    ElasticSearch入门-搜索(java api) package com.qlyd.searchhelper; import java.util.Map; import net.sf.json ...

  5. PHP使用ElasticSearch做搜索

    PHP 使用 ElasticSearch 做搜索 https://blog.csdn.net/zhanghao143lina/article/details/80280321 https://www. ...

  6. 十九种Elasticsearch字符串搜索方式终极介绍

    前言 刚开始接触Elasticsearch的时候被Elasticsearch的搜索功能搞得晕头转向,每次想在Kibana里面查询某个字段的时候,查出来的结果经常不是自己想要的,然而又不知道问题出在了哪 ...

  7. Elasticsearch实现搜索推荐词

    本篇介绍的是基于Elasticsearch实现搜索推荐词,其中需要用到Elasticsearch的pinyin插件以及ik分词插件,代码的实现这里提供了java跟C#的版本方便大家参考. 1.实现的结 ...

  8. Elasticsearch 为了搜索

    前言 Elasticsearch 是一个开源的搜索引擎,建立在一个全文搜索引擎库 Apache Lucene 基础之上. Lucene 可以说是当下最先进.高性能.全功能的搜索引擎库--无论是开源还是 ...

  9. Elasticsearch分布式搜索和数据分析引擎-ElasticStack(上)v7.14.0

    Elasticsearch概述 **本人博客网站 **IT小神 www.itxiaoshen.com Elasticsearch官网地址 https://www.elastic.co/cn/elast ...

随机推荐

  1. Docker (error getsockopt: connection refused ,使用http无法使用 docker login 登录的问题)

    因部署Harbor 镜像仓库,部署完了之后根据提示上传 images,需要使用docker  login   ip:port  进行登录, 登录的时候发现因为docker 默认是https,因为测试环 ...

  2. scp命令------两服务器之间传输数据

    scp就是secure copy,是用来进行远程文件拷贝的.数据传输使用 ssh,并且和ssh 使用相同的认证方式,提供相同的安全保证 . 与rcp 不同的是,scp 在需要进行验证时会要求你输入密码 ...

  3. KVM (虚拟化网络管理)

    vlan:https://www.cnblogs.com/du-z/p/10802786.html trunk:https://www.cnblogs.com/du-z/p/10804773.html ...

  4. 《C++ Primer Plus》啃书计 第1~4章

    <C++ Primer Plus>啃书计 第1~4章 第一章 预备知识 1.1-1.3略过 1.4 程序创建的技巧 1. cfront,它将C++源代码翻译成C源代码,然后再使用标准C编译 ...

  5. B - B(Is It A Tree?)

    给出一堆边给你,让你判断这是不是一棵树.边的信息以(start , end)的形式给出. A tree is a well-known data structure that is either em ...

  6. [CF套题] CF-1163

    CF-1163 传送门 # Penalty A B1 B2 C1 C2 D E F 3 (483) 464 +0 0:06 +1 01:13 +3 01:12 + 01:57 + 01:56 A 第一 ...

  7. Codeforces Round #625 (Div. 2, based on Technocup 2020 Final Round) C. Remove Adjacent(字符串,贪心,枚举)

    题意: 给你一个由小写字母组成的字符串,若串中两个相邻元素字典序中也相邻,移除较大字母,问最多能移除多少个字母. 思路: 从大到小依次枚举. Tips: 注意下标的处理. 以小消大: #include ...

  8. Educational Codeforces Round 9 C. The Smallest String Concatenation(字符串排序)

    You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in some or ...

  9. Atcoder ABC162 D - RGB Triplets

    传送门:D - RGB Triplets  题意:给你一个只含'R','G','B'的字符串,求有多少个长度为3且每个字符都不相等,并且第一第二和第二第三的区间长度不同的子序列. 题解:统计每个字符各 ...

  10. Qt内部的d指针和q指针手把手教你实现

    Qt内部的d指针和q指针 在讲Qt的D指针之前让我们来简单的解释一下D指针出现的目的,目的是什么呢?保证模块间的二进制兼容. 什么是二进制兼容呢,简单说就是如果自己的程序使用了第三方模块,二进制兼容可 ...