gpt4 book ai didi

elasticsearch - Elasticsearch 中来自获取请求的CSV响应

转载 作者:行者123 更新时间:2023-12-03 00:06:52 25 4
gpt4 key购买 nike

我正在向 flex 搜索服务器发送http Get请求,并且我希望响应为csv格式。就像solr一样,我们可以指定wt = csv在 flex 搜索中也可以吗?
我的查询是:

enter code here
http://elasticServer/_search?q=RCE:"some date" OR
VENDOR_NAME:"Anuj"&from=0&size=5&sort=@timestamp


-----After that i want to force the server to return me response in csv format

最佳答案

默认情况下,ES仅支持两种数据格式:JSON和YAML。但是,如果您愿意使用Logstash,则可以像下面这样轻松实现所需的功能:

input {
elasticsearch {
hosts => ["localhost:9200"]
query => 'RCE:"some date" OR VENDOR_NAME:"Anuj"'
size => 5
}
}
filter {}
output {
csv {
fields => ["field1", "field2", "field3"]
path => "/path/to/data.csv"
}
}

由于 elasticsearch输入使用滚动,因此您无法指定任何排序。因此,如果排序对您确实很重要,则可以使用 http_poller input而不是 elasticsearch一个,如下所示:
input {
http_poller {
urls => {
es => {
method => get
url => 'http://elasticServer/_search?q=RCE:"some date" OR VENDOR_NAME:"Anuj"&from=0&size=5&sort=@timestamp'
headers => {
Accept => "application/json"
}
}
}
codec => "json"
}
}
filter {}
output {
csv {
fields => ["field1", "field2", "field3"]
path => "/path/to/data.csv"
}
}

关于elasticsearch - Elasticsearch 中来自获取请求的CSV响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44361904/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com