create_index.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/usr/bin/env bash
  2. curl -XDELETE 'http://192.168.0.109:9200/index/'
  3. curl -XPUT 'http://192.168.0.109:9200/index/' -d '{
  4. "settings": {
  5. "index": {
  6. "number_of_shards": 1,
  7. "number_of_replicas": 0
  8. }
  9. },
  10. "mappings": {
  11. "product": {
  12. "properties": {
  13. "productName": {
  14. "type": "string",
  15. "index": "not_analyzed"
  16. },
  17. "productCode": {
  18. "type": "string",
  19. "index": "not_analyzed"
  20. },
  21. "minPrice": {
  22. "type": "double"
  23. },
  24. "advicePrice": {
  25. "type": "double"
  26. },
  27. "provider": {
  28. "type": "object",
  29. "properties": {
  30. "providerName": {
  31. "type": "string",
  32. "index": "not_analyzed"
  33. },
  34. "providerLevel" : {
  35. "type": "integer"
  36. }
  37. }
  38. },
  39. "buyers": {
  40. "type": "nested",
  41. "properties": {
  42. "buyerName": {
  43. "type": "string",
  44. "index": "not_analyzed"
  45. },
  46. "productPrice": {
  47. "type": "double"
  48. }
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }'
  55. curl -XPUT 'http://192.168.0.109:9200/index/product/1' -d '{
  56. "productName" : "iphone 6s",
  57. "productCode" : "IP_6S",
  58. "minPrice" : 2288.00,
  59. "advicePrice" : "6288.00",
  60. "provider" : {
  61. "providerName" : "foxconn",
  62. "providerLevel" : 1
  63. },
  64. "buyers" : [{
  65. "buyerName" : "china",
  66. "productPrice" : 9288.00
  67. },
  68. {
  69. "buyerName" : "usa",
  70. "productPrice" : 3288.00
  71. },
  72. {
  73. "buyerName" : "japan",
  74. "productPrice" : 4288.00
  75. }]
  76. }'
  77. curl -XPUT 'http://192.168.0.109:9200/index/product/2' -d '{
  78. "productName" : "apple watch os2",
  79. "productCode" : "AW_OS2",
  80. "minPrice" : 1000.00,
  81. "advicePrice" : "5000.00",
  82. "provider" : {
  83. "providerName" : "foxconn",
  84. "providerLevel" : 1
  85. },
  86. "buyers" : [{
  87. "buyerName" : "china",
  88. "productPrice" : 9999.00
  89. },
  90. {
  91. "buyerName" : "usa",
  92. "productPrice" : 4500.00
  93. },
  94. {
  95. "buyerName" : "japan",
  96. "productPrice" : 6000.00
  97. }]
  98. }'
  99. curl -XPOST 'http://192.168.0.109:9200/index/_refresh'