curl -H“内容类型:application / json” -XPOST'https://mydomain/'-d @ cps_index.json
JSON文件中的内容
{
"settings": {
"mappings": {
"_source": {
"enabled": false
},
"cps": {
"properties": {
"firstName": {
"type": "text"
},
"lastname": {
"type": "text"
},
"email": {
"type": "text"
},
"mobileNumber": {
"type": "keyword"
},
"employeeId": {
"type": "keyword"
}
}
}
}
}
}
失败,响应消息 {“错误”:“ uri [/]和方法[POST]的HTTP方法不正确,允许:[GET,HEAD,DELETE]”,“状态”:405 }
答案 0 :(得分:2)
几个问题:
Content = '''// <![CDATA[
devicetype = "computer";
isios = false;
videocdn = "media";
videopath = "updates/na/vid01";
poster = {"file": "preview/vidsplash.jpg","st": "1557499029","et": "1557502629","hs": "f3ad16f42fec5224d323915cdfbf43ed"};
attachname = "some-video-00001234";'''
import json
results = {}
for line in Content.split('\n'):
if ' = ' in line:
line = line[:-1] # remove `;`
key, val = line.split(' = ', 1)
if val.startswith( ('[', '{') ):
results[key] = json.loads(val)
elif val.startswith('"'):
val = val[1:-1] # remove `"`
results[key] = val
elif val == 'false':
results[key] = False
elif val == 'true':
results[key] = True
print(results['devicetype'])
print(results['isios'])
print(results['videocdn'])
print(results['poster']['file'])
# computer
# False
# media
# preview/vidsplash.jpg
嵌套到mappings
执行此操作:
像这样修改cps_index.json:
settings
运行此:
{
"mappings": {
"doc": {
"_source": {
"enabled": false
},
"properties": {
"firstName": {
"type": "text"
},
"lastname": {
"type": "text"
},
"email": {
"type": "text"
},
"mobileNumber": {
"type": "keyword"
},
"employeeId": {
"type": "keyword"
}
}
}
}
}
答案 1 :(得分:1)
您需要在https://mydomain
之后添加索引名称https://mydomain/indexname