Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8422831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:33:59+00:00 2026-06-10T03:33:59+00:00

I am just starting with elasticsearch. I want to query using cURL in php.

  • 0

I am just starting with elasticsearch. I want to query using cURL in php.

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…)

$url = "curl -s -XGET http://<my_url>: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);

but if I use this url http://<my_url>:9200/idx_occurrence/Occurrence/_search?q=kingdom_interpreted:Plantae

then I get results from cURL.

Maybe may query filter is incorrect? (I tried several options without success)

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}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:34:00+00:00Added an answer on June 10, 2026 at 3:34 am

    I have been using the Elastica PHP library for my elasticsearch interactions:

    https://github.com/ruflin/Elastica

    It had a very short learning curve. Here’s an example:

    $client = new Elastica_Client();
    $index = $client->getIndex('idx_occurrence');
    $index->getType('Occurrence');
    
    $query_string = new Elastica_Query_QueryString('Plantae');
    $query_string->setFields(array('kingdom_interpreted'));    
    $query = new Elastica_Query($query_string);
    
    $index->refresh();
    $searchResults = $index->search($query);
    

    This illustrates a Query String search limited to a specific field. $searchResults is an array of Elastica_ResultSet objects. I like Elastica because it abstracts away any cURL-related issues.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just starting to approach this problem, I want to to allow users to
Hi just starting to learn this language, more of a javascript/PHP guy... I can't
Just starting with php and sorry if this is a newbie question but i'm
Just starting up with iPhone development. I'm not sure why this code works. I've
I just starting using VS2005 and I wish to have code highlighting in C/C++.
im just starting to learn about sockets and i have been given this code,
Just starting with Modelica and having trouble understanding how it works. In the below
Just starting to learn ASP.NET (C#) and I am using Visual Studio 2008. I
Just starting out, this should be a simple one but I haven't been able
Just starting out with an iPhone application using xcode 4.2. I understand that it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.