gpt4 book ai didi

rest - 如何在elasticsearch上使用 “REST request URI”做范围过滤器?

转载 作者:行者123 更新时间:2023-12-02 22:48:55 25 4
gpt4 key购买 nike

我在ES上有以下简单数据:

curl -XPUT localhost:9200/dt/art/1 -d '{ "age": 77 }'
curl -XPUT localhost:9200/dt/art/2 -d '{ "age": 19 }'
curl -XPUT localhost:9200/dt/art/3 -d '{ "age": 42 }'
curl -XPUT localhost:9200/dt/art/4 -d '{ "age": 33 }'

是否可以使用“ REST request URI”对“年龄”进行范围过滤?

现在,我只能通过“ REST request body”来获得它:
$ curl "localhost:9200/dt/art/_search?pretty" -d'{
"query": {
"bool": { "must": { "match_all": {} },
"filter": {
"range": {
"age": { "gte": 20, "lte": 50}}}}}}'


{ "took" : 8, "timed_out" : false,
"_shards" : { "total" : 5, "successful" : 5, "skipped" : 0, "failed" : 0 },
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [
{ "_index" : "dt", "_type" : "art", "_id" : "4", "_score" : 1.0,
"_source" : { "age" : 33 } },
{ "_index" : "dt", "_type" : "art", "_id" : "3", "_score" : 1.0,
"_source" : { "age" : 42 } }
]
}
}
$

最佳答案

是。

GET dt/art/_search?q=age:[19+TO+50]

对于日期,您可以使用类似这样的内容
_search?q=metrictype:os+datetime:[\"2016-08-30 10:00:00\"+to+\"2016-08-30 10:30:00\" ]+fields:datetime,cpu,disk"

关于rest - 如何在elasticsearch上使用 “REST request URI”做范围过滤器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46391107/

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