elasticsearch - Elasticsearch REST 搜索 API
问题描述
我对 elasticsearch nad REST API 的远程地址有问题(获取搜索结果)
我正在使用由 jHispter (logstash + Elasticsearch + Kibana) 创建的 ELK 堆栈。当我使用带有外部服务器地址的 REST 搜索 API(通过 cURL)时,我得到的结果比使用 localhost 时要少:
$ curl -X GET "http://localhost:9200/logstash-*/_search?q=Method:location"
{"took":993,"timed_out":false,"num_reduce_phases":13,"_shards":
{"total":6370,"successful":6370,"skipped":0,"failed":0},"hits":
{"total":8994099,"max_score":5.0447145,"hits":[..]}}
当从不同的服务器执行时,它返回较少数量的碎片和命中:
$ curl -X GET "http://SERVER_URL/logstash-*/_search?q=Method:location"
{"took":10,"timed_out":false,"_shards":
{"total":120,"successful":120,"skipped":0,"failed":0},"hits":
{"total":43,"max_score":7.5393815,"hits":[..]}}
如果我创建 ssh 隧道,它可以工作:
ssh -L 9201:SERVER_URL:9200 elk-stack
现在:
$ curl -X GET "localhost:9201/logstash-*/_search?q=Method:location"
{"took":640,"timed_out":false,"num_reduce_phases":13,"_shards":
{"total":6370,"successful":6370,"skipped":0,"failed":0},"hits":
{"total":8995082,"max_score":5.0447145,"hits":[..]}}
所以访问本地主机之外的数据肯定有一些问题,但我无法在配置中找到如何更改它(可能是某种默认行为以防止从远程访问时数据泄漏?)
解决方案
你应该配置你的主机
为此,在 config/elasticsearch.yml 文件中放入这一行:
network.host: 0.0.0.0
推荐阅读
- python - Tensorflow classification predictions
- julia - Julia using argmax to return index within a row of a matrix instead of a CartesianIndex
- ruby-on-rails - 像访问本机模型一样访问 ActiveStorageBlob 或 ActiveStorageAttachment
- javascript - How can i make anchor tags clickable when using the function z index
- python - 如何同时使用 pandas/python 对多列中的数据进行 bin 处理?
- google-apps-script - 将数据导入 Google 表格时在 Apps 脚本中处理时区
- ajax - 具有两种分类法的自定义帖子类型的 Wordpress 多 ajax 过滤
- python - 从附加的csv(熊猫)中删除第一列中基于“,,,,,,”值的空行
- firebase - 意外的令牌文档?Firebase 部署
- python - 如何创建带有图像 ID 和相应标签的 csv 文件?