elasticsearch 索引 mapping一起创建

张映 发表于 2018-05-19

分类目录: elasticsearch, 服务器相关

标签:, ,

创建索引,创建mapping可以分开创建,但有的时候,我们是需要一起创建。

  1. MacBook-Pro:question_api zhangying$ curl -XPUT "http://localhost:9200/tank1/?pretty" -H "Content-Type: application/json" -d' 
  2. > { 
  3. >     "mappings" : { 
  4. >       "test": { 
  5. >             "_all":{ 
  6. >               "enabled":false 
  7. >             }, 
  8. >             "properties": { 
  9. >                 "id": { 
  10. >                     "type": "integer" 
  11. >                 }, 
  12. >                 "username": { 
  13. >                     "type": "text", 
  14. >                     "analyzer": "ik_pinyin_analyzer" 
  15. >                 }, 
  16. >                 "description": { 
  17. >                     "type": "text", 
  18. >                     "analyzer": "ik_pinyin_analyzer" 
  19. >                 } 
  20. >             } 
  21. >         } 
  22. >     }, 
  23. >     "settings" : { 
  24. >         "analysis": { 
  25. >             "analyzer": { 
  26. >                 "ik_pinyin_analyzer": { 
  27. >                     "type": "custom", 
  28. >                     "tokenizer": "ik_max_word", 
  29. >                     "filter": ["my_pinyin", "word_delimiter"] 
  30. >                 } 
  31. >             }, 
  32. >             "filter": { 
  33. >                 "my_pinyin": { 
  34. >                     "type": "pinyin" 
  35. >                 } 
  36. >             } 
  37. >         } , 
  38. >         "number_of_shards" : "5", 
  39. >         "number_of_replicas" : "0" 
  40. >     } 
  41. > }'  
  42. {  
  43.   "acknowledged" : true,  
  44.   "shards_acknowledged" : true,  
  45.   "index" : "tank1"  
  46. }  

 



转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/server/1920.html