Please change the enclosing quotes from ' to " also escape the quotation marks " used inside the parameters as below and run the curl command :
curl -XGET gitlab.server:9200/ -H "Content-Type: application/json" -d "{\"query\": {\"simple_query_string\" : {\"fields\" : [\"content\"], \"query\" : \"foo bar -baz\"}}}"
An alternative is also available to put the json into a file, and use the @ prefix for the parameters.
json.txt
{ "query": { "simple_query_string" : { "fields" : ["content"], "query" : "foo bar -baz" } } }
After doing that run the curl command as below:
curl -XGET gitlab.server:9200/ -H "Content-Type: application/json" -d @json.txt