windows下安裝 crul 以及windows下使用的注意事項

主要記錄在windows下安裝 crul 以及windows下使用的注意事項.

1. curl 下載:
http://www.paehl.com/open_source/?CURL_7.49.1

2. curl windows 下可視化工具下載
http://www.paehl.com/open_source/?CURL_7.49.1___GUI_for_CURL_0.1

如果是linux 下, 可以用類似的命令增加一條索引.
程序代碼 程序代碼

curl -XPUT 'localhost:9200/mycompany/employee/1' -d '{"first_name":"John","last_name":"Smith","age":25,"about":"Ilovetogorockclimbing","interests":["sports","music"]}'

windows下,要這樣做,注意引號. 否則會報錯:

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse"}],"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"not_x_content_exception","reason":"Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"}},"status":400}
windows 正確的做法:
程序代碼 程序代碼

curl -XPUT "localhost:9200/mycompany/employee/1" -d "{"""first_name""":"""John""","""last_name""":"""Smith""","""age""":25,"""about""":"""Ilovetogorockclimbing""","""interests""":["""sports""","""music"""]}"

程序代碼 程序代碼

curl -XPUT "localhost:9200/mycompany/employee/2" -d "{"""first_name""":"""Jane""","""last_name""":"""Smith""","""age""":32,"""about""":"""Iliketocollectrockalbums""","""interests""":["""music"""]}"

程序代碼 程序代碼

curl -XPUT "localhost:9200/mycompany/employee/3" -d "{"""first_name""":"""Douglas""","""last_name""":"""Fir""","""age""":35,"""about""":"""Iliketobuildcabinets""","""interests""":["""forestry"""]}"

嘗試得到一個索引:
curl -XGET "localhost:9200/mycompany/employee/1"

返回如下內容:
{"_index":"mycompany","_type":"employee","_id":"1","_version":1,"found":true,"_source":{"first_name":"John","last_name":"Smith","age":25,"about":"Ilovetogorockclimbing","interests":["sports","music"]}}

Java client 操作時一定要先修改配置文件:
network.host: 192.168.10.29 或者修改爲  0.0.0.0
這裏是你機器的IP 地址,不要用localhost 或者  127.0.0.1, 否則很容易報錯:

NoNodeAvailableException[None of the configured nodes are available



原文地址:http://www.yihaomen.com/article/java/630.htm

發佈了14 篇原創文章 · 獲贊 5 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章