window下elasticsearch使用curl,来建立索引:
curl -XPUT "http://localhost:9200/my_index" -d "
{"settings":{"number_of_shards":3,
"number_of_replicas": 1},
"mappings": {"employee": {"properties":
{"first_name": { "type": "string"}, "last_name":
{"type": "string"}, "age": {"type": "integer"},"about":
{"type": "string"}, "interests": {"type": "string" },
"join_time": {"type": "date",
"format": "dateOptionalTime", "index":"not_analyzed"} }}}}"
运行出现错误:
参考博客http://blog.youkuaiyun.com/long243416336/article/details/50486883,说是把引号变成三个引号
curl -XPUT "http://localhost:9200/my_index" -d "{"""settings""":{"""number_of_shards""":3,
"""number_of_replicas""": 1},"""mappings""": {"""employee""": {"""properties""": {"""first_name""": { """type""": """string"""}, """last_name""": {"""type""": """string"""}, """age""": {"""type""": """integer"""}, """about""": {"""type""": """string"""}, """interests""": {"""type""": """string""" }, """join_time""": {"""type""": """date""", """format""": """dateOptionalTime""", """index""": """not_analyzed"""} }}}}"
运行成功!!1
还有一点是在建索引之前不要建一个已经存在的索引名字,不然会出错