数据准备

  • 自定义词库
    • 慕课网
    • 慕课
    • 课网
  • 建立索引 shop(名字随意)
  • 手动建立mappings ```json POST /shop/_mapping { “properties”: {
    1. "id": {
    2. "type": "long"
    3. },
    4. "age": {
    5. "type": "integer"
    6. },
    7. "username": {
    8. "type": "keyword"
    9. },
    10. "nickname": {
    11. "type": "text",
    12. "analyzer": "ik_max_word"
    13. },
    14. "money": {
    15. "type": "float"
    16. },
    17. "desc": {
    18. "type": "text",
    19. "analyzer": "ik_max_word"
    20. },
    21. "sex": {
    22. "type": "byte"
    23. },
    24. "birthday": {
    25. "type": "date"
    26. },
    27. "face": {
    28. "type": "text",
    29. "index": false
    30. }
    } }
  1. - 录入数据
  2. ```json
  3. POST /shop/_doc/1001
  4. {
  5. "id": 1001,
  6. "age": 18,
  7. "username": "imoocAmazing",
  8. "nickname": "慕课网",
  9. "money": 88.8,
  10. "desc": "我在慕课网学习java和前端,学习到了很多知识",
  11. "sex": 0,
  12. "birthday": "1992-12-24",
  13. "face": "https://www.imooc.com/static/img/index/logo.png"
  14. }
  15. {
  16. "id": 1002,
  17. "age": 19,
  18. "username": "justbuy",
  19. "nickname": "周杰棍",
  20. "money": 77.8,
  21. "desc": "今天上下班都很堵,车流量很大",
  22. "sex": 1,
  23. "birthday": "1993-01-24",
  24. "face": "https://www.imooc.com/static/img/index/logo.png"
  25. }
  26. {
  27. "id": 1003,
  28. "age": 20,
  29. "username": "bigFace",
  30. "nickname": "飞翔的巨鹰",
  31. "money": 66.8,
  32. "desc": "慕课网团队和导游坐飞机去海外旅游,去了新马泰和欧洲",
  33. "sex": 1,
  34. "birthday": "1996-01-14",
  35. "face": "https://www.imooc.com/static/img/index/logo.png"
  36. }
  37. {
  38. "id": 1004,
  39. "age": 22,
  40. "username": "flyfish",
  41. "nickname": "水中鱼",
  42. "money": 55.8,
  43. "desc": "昨天在学校的池塘里,看到有很多鱼在游泳,然后就去慕课网上课了",
  44. "sex": 0,
  45. "birthday": "1988-02-14",
  46. "face": "https://www.imooc.com/static/img/index/logo.png"
  47. }
  48. {
  49. "id": 1005,
  50. "age": 25,
  51. "username": "gotoplay",
  52. "nickname": "ps游戏机",
  53. "money": 155.8,
  54. "desc": "今年生日,女友送了我一台play station游戏机,非常好玩,非常不错",
  55. "sex": 1,
  56. "birthday": "1989-03-14",
  57. "face": "https://www.imooc.com/static/img/index/logo.png"
  58. }
  59. {
  60. "id": 1006,
  61. "age": 19,
  62. "username": "missimooc",
  63. "nickname": "我叫小慕",
  64. "money": 156.8,
  65. "desc": "我叫凌云慕,今年20岁,是一名律师,我在琦䯲星球做演讲",
  66. "sex": 1,
  67. "birthday": "1993-04-14",
  68. "face": "https://www.imooc.com/static/img/index/logo.png"
  69. }
  70. {
  71. "id": 1007,
  72. "age": 19,
  73. "username": "msgame",
  74. "nickname": "gamexbox",
  75. "money": 1056.8,
  76. "desc": "明天去进货,最近微软处理很多游戏机,还要买xbox游戏卡带",
  77. "sex": 1,
  78. "birthday": "1985-05-14",
  79. "face": "https://www.imooc.com/static/img/index/logo.png"
  80. }
  81. {
  82. "id": 1008,
  83. "age": 19,
  84. "username": "muke",
  85. "nickname": "慕学习",
  86. "money": 1056.8,
  87. "desc": "大学毕业后,可以到imooc.com进修",
  88. "sex": 1,
  89. "birthday": "1995-06-14",
  90. "face": "https://www.imooc.com/static/img/index/logo.png"
  91. }
  92. {
  93. "id": 1009,
  94. "age": 22,
  95. "username": "shaonian",
  96. "nickname": "骚年轮",
  97. "money": 96.8,
  98. "desc": "骚年在大学毕业后,考研究生去了",
  99. "sex": 1,
  100. "birthday": "1998-07-14",
  101. "face": "https://www.imooc.com/static/img/index/logo.png"
  102. }
  103. {
  104. "id": 1010,
  105. "age": 30,
  106. "username": "tata",
  107. "nickname": "隔壁老王",
  108. "money": 100.8,
  109. "desc": "隔壁老外去国外出差,带给我很多好吃的",
  110. "sex": 1,
  111. "birthday": "1988-07-14",
  112. "face": "https://www.imooc.com/static/img/index/logo.png"
  113. }
  114. {
  115. "id": 1011,
  116. "age": 31,
  117. "username": "sprder",
  118. "nickname": "皮特帕克",
  119. "money": 180.8,
  120. "desc": "它是一个超级英雄",
  121. "sex": 1,
  122. "birthday": "1989-08-14",
  123. "face": "https://www.imooc.com/static/img/index/logo.png"
  124. }
  125. {
  126. "id": 1012,
  127. "age": 31,
  128. "username": "super hero",
  129. "nickname": "super hero",
  130. "money": 188.8,
  131. "desc": "BatMan, GreenArrow, SpiderMan, IronMan... are all Super Hero",
  132. "sex": 1,
  133. "birthday": "1980-08-14",
  134. "face": "https://www.imooc.com/static/img/index/logo.png"
  135. }