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 8726711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:18:14+00:00 2026-06-13T08:18:14+00:00

How do I execute the below query(given in doc ) using rest client. curl

  • 0

How do I execute the below query(given in doc) using rest client.

curl -XGET 'http://localhost:9200/twitter/tweet/_search' -d '{
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}
'

I tried doing this:

q = '{
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}
'

r = JSON.parse(RestClient.get('http://localhost:9200/twitter/tweet/_search', q))

This threw up an error:

in `process_url_params': undefined method `delete_if' for #<String:0x8b12e18>     (NoMethodError)
    from /home/socialapps/.rvm/gems/ruby-1.9.3-p194/gems/rest-client-1.6.7/lib/restclient/request.rb:40:in `initialize'
    from /home/socialapps/.rvm/gems/ruby-1.9.3-p194/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `new'
    from /home/socialapps/.rvm/gems/ruby-1.9.3-p194/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
    from /home/socialapps/.rvm/gems/ruby-1.9.3-p194/gems/rest-client-1.6.7/lib/restclient.rb:68:in `get'
    from get_check2.rb:12:in `<main>'

When I do the same using RestClient.post, it gives me the right results!. But the elasticsearch doc uses XGET in curl command for the search query and not XPOST. How do I get the RestClient.get method to work?

If there are alternate/better ways of doing this action, please suggest.

  • 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-13T08:18:17+00:00Added an answer on June 13, 2026 at 8:18 am

    RestClient can’t send request bodies with GET. You’ve got two options:

    Pass your query as the source URL parameter:

    require 'rest_client'
    require 'json'
    
    # RestClient.log=STDOUT # Optionally turn on logging
    
    q = '{
        "query" : { "term" : { "user" : "kimchy" } }
    }
    '
    r = JSON.parse \
          RestClient.get( 'http://localhost:9200/twitter/tweet/_search',
                          params: { source: q } )
    
    puts r
    

    …or just use POST.


    UPDATE: Fixed incorrect passing of the URL parameter, notice the params Hash.

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

Sidebar

Related Questions

One of the query (given below) is taking 90+ seconds to execute. It returns
I have this below query that I execute using java PreparedStatement: String dml=insert into
When I try to execute the below class using ICriteria, if (_userGroupId > 0
When I execute the code saveXML below it generates the error above, why?? using
I have a problem when trying to execute this update statement (below) using C#
I'm retrieving the files that match a given query in my drive account using
I am just starting with elasticsearch. I want to query using cURL in php.
How can I execute the results of my select query. The query below gives
I am using the below SQL query but it takes more than 180 sec
I am trying to execute the below query. I am getting the same column,

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.