title: elasticsearch query and cURL in PHP
body: <p>I am just starting with elasticsearch. I want to query using cURL in php.</p>
  
  <p>This code gives nothing... (see error below if I execute from command line. I am not sure that this error is caused of line breaks in console...)</p>
  
  <pre><code>$url = "curl -s -XGET http://&lt;my_url&gt;:9200/idx_occurrence/Occurrence/_search -d '
  {
  'filtered' : {
      'query' : {
          'term' : { 'kingdom_interpreted' : 'Plantae' }
      }
  }
  
  }' ";
  
  $ch = curl_init();
  
  curl_setopt($ch, CURLOPT_URL, $url);
  
  curl_setopt($ch, CURLOPT_HEADER, 0);
  
  $return=curl_exec($ch);
  
  var_dump($return);
  </code></pre>
  
  <p>but if I use this url <code>http://&lt;my_url&gt;:9200/idx_occurrence/Occurrence/_search?q=kingdom_interpreted:Plantae</code></p>
  
  <p>then I get results from cURL.</p>
  
  <p>Maybe may query filter is incorrect? (I tried several options without success)</p>
  
  <blockquote>
    <p>ERROR: {"error":"SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[AS6HqxgNRtyU9-pQKhJsXQ][idx_occurrence][3]: SearchParseException[[idx_occurrence][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n    filtered : {\n        query : {\n            term : { kingdom : Plantae }\n        }\n}\n}]]]; nested: SearchParseException[[idx_occurrence][3]: from[-1],size[-1]: Parse Failure [No parser for element [filtered]]]; }{[AS6HqxgNRtyU9-pQKhJsXQ][idx_occurrence][2]: SearchParseException[[idx_occurrence][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n    filtered : {\n        query : {\n            term : { kingdom : Plantae }\n        }\n}\n}]]]; nested: SearchParseException[[idx_occurrence][2]: from[-1],size[-1]: Parse Failure [No parser for element [filtered]]]; }]","status":500}</p>
  </blockquote>