elastic-query-export icon indicating copy to clipboard operation
elastic-query-export copied to clipboard

issue with raw query

Open htrmind7 opened this issue 2 years ago • 2 comments

I've tried the following windows command : elastic-query-export.exe -c "http://localhost:9200" -i "myindex-*" --start="2022-09-27T00:00:00" --fields="foo,bar" -r '{"bool":{"filter":{"bool":{"must":[{"range":{"date":{"from":"2022-09-27T00:00:00.000","include_lower":true,"include_upper":false,"time_zone":"+02:00","to":"2022-09-28T12:20:00.000"}}}]}}}}' -f "csv" -o "test_export_es.csv"

and got this error in return Error counting ElasticSearch documents - invalid character '\'' looking for beginning of value invalid character '\'' looking for beginning of value

htrmind7 avatar Sep 28 '22 10:09 htrmind7

I tried it several times with the same query you provided and it worked all the time. It's also not fully clear if the errors comes from your query input or from the response of the Elasticsearch server. It looks like maybe the shell adds some additional escaping (because of the in ).

pteich avatar Oct 19 '23 20:10 pteich

Thanks @pteich for making this great tool. I am just wondering how I can use the size: and sort: with the raw query. In my tests, it could not work with -r '{"size":1,"sort":[{"@timestamp":{"order":"desc"}}],"query":{"bool":{"must":[{"query_string":{"query":"tags:test}}],"filter":[{"range":{"@timestamp":{"from":"2023-04-22T00:00:00.000"}}}]}}}' but it can work well without size and sort. Do you know how I can make it working with size and sort? Thank you!

Simonhua9 avatar Apr 23 '24 18:04 Simonhua9