参考ページ
Search API Filters
サンプルの
national-parks-demo
を使います。
Curl
filter_curl.sh
HOST="https://mar29-project.ent.asia-northeast1.gcp.cloud.es.io"
SEARCH_KEY="search-******"
NAME_ENGINE="national-parks-demo"
#
#
curl -X POST ${HOST}'/api/as/v1/engines/'$NAME_ENGINE'/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer '${SEARCH_KEY} \
-d '{
"query": "",
"filters" : {
"states": [ "Texas", "Minnesota" ]
}
}'
go_curl.sh
./filter_curl.sh > out01.json
jq .results[].states out01.json
実行結果
$ ./go_curl.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2646 100 2573 100 73 5105 144 --:--:-- --:--:-- --:--:-- 5302
{
"raw": [
"Texas"
]
}
{
"raw": [
"Minnesota"
]
}
{
"raw": [
"Texas"
]
}
Httpie
filter_http.sh
HOST="https://mar29-project.ent.asia-northeast1.gcp.cloud.es.io"
SEARCH_KEY="search-******"
NAME_ENGINE="national-parks-demo"
#
#
http ${HOST}'/api/as/v1/engines/'$NAME_ENGINE'/search' \
'Authorization: Bearer '${SEARCH_KEY} < query01.json
query01.json
{
"query": "",
"filters" : { "states": [ "Texas", "Minnesota" ] }
}
go_http.sh
./filter_http.sh > out02.json
jq .results[].states out02.json
実行結果
$ ./go_http.sh
{
"raw": [
"Texas"
]
}
{
"raw": [
"Minnesota"
]
}
{
"raw": [
"Texas"
]
}