Issue
I have a .csv
file that contains 2500 unique request id like "4485-182-65846".
I want to run a elasticsearch query command that contain this request Id.
my query be like:
curl -XGET 127.0.0.1:9200/_search?pretty -d '
{
"query": {
"match": {
"request_id": "$VARIABLE(contents of the file)"
}
}
}' > answer.csv
Now I want to put every unique id into a VARIBALE and run the query to answer them in a specific file
I would appreciate any help.
I tried this code but did not answer
request_id=(cat file.csv)
for i in request_id;
do
curl -XGET 127.0.0.1:9200/_search?pretty -d '
{
"query": {
"match": {
"request_id": "$i"
}
}
}' > answer.csv
Solution
Thank you guys for your attention and answers, this worked for me:
VAR=$(cat file1.txt)
for i in $VAR;
do
curl --user userpasswrd:password -XGET "http://127.0.0.1:9200/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"match": {
"log.request_id": '$i'
}
}
}' >> answer.csv
note: I had to save the file1.txt with UTF8 encoding and put all request id between double quotation
Answered By - Amirhossein eidy Answer Checked By - Willingham (WPSolving Volunteer)