您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
配置elasticSearch-head连接elasticSearch服务
发布时间:2021-08-20 16:12:51编辑:雪饮阅读()
上次配置安装了elastic-head,只是打开了一个前端界面,那么具体要使用elastic-head去连接elasticSearch服务的时候又发现了问题
点击那个“连接”按钮怎么都是连接不上,那么此时若打开f12查看network,你会发现错误其实是源自于跨域问题。
那么我们打开如:elasticsearch-7.14.0\config\elasticsearch.yml去配置下跨越权限
在末尾加上如下:
http.cors.enabled: true
http.cors.allow-origin: "*"
加上这两行配置即可解决跨域问题,但是对于第二行这里是偷懒了,直接允许任何来访者进行跨域,实际上应该是比如限制让某个网址的来源可以允许跨域。
那么此时重启下elasticSearch服务,再次在elastic-head中去“连接”就可以连接成功了。
这里这个schools_gov是我用_bulk批量创建的,
其请求:
http://localhost:9200/schools_gov/_bulk POST
其批量创建的请求正文如:
{"index":{"_index":"schools_gov", "_type":"school", "_id":"1"}}
{"name":"Model School", "description":"CBSE Affiliation", "street":"silk city","city":"Hyderabad", "state":"AP", "zip":"500030", "location":[17.3903703, 78.4752129],"fees":200, "tags":["Senior Secondary", "beautiful campus"], "rating":"3"}
{"index":{"_index":"schools_gov", "_type":"school", "_id":"2"}}
{"name":"Government School", "description":"State Board Affiliation","street":"Hinjewadi", "city":"Pune", "state":"MH", "zip":"411057","location": [18.599752, 73.6821995], "fees":500, "tags":["Great Sports"], "rating":"4"}
关键字词:elasticSearch-head,连接,elasticSearch