0

In this ElasticSearch document it explains how to submit a query:

GET /_search
{
    "query": {
        "match" : {
            "message" : "this is a test"
        }
    }
}

But a GET doesn't have a body, it's just a link to get a document.

The related CURL in the documentation:

curl -X GET "localhost:9200/_search" -H 'Content-Type: application/json' -d'
{
    "query": {
        "match" : {
            "message" : "this is a test"
        }
    }
}
'

If I read the meaning of -d in CURL documentation, it says

-d, --data

(HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button.

Meaning that the GET should be converted to a POST? I'm confused, from a Java program do I need to submit a GET or a POST to the ElasticSearch engine?

ps0604
  • 1,227
  • 23
  • 133
  • 330
  • 1
    This answer may also help: https://stackoverflow.com/questions/34795053/es-keeps-returning-every-document/34796014#34796014 – Val Apr 15 '19 at 16:15

1 Answers1

1

Elasticsearch _search endpoint does support GET and POST Request Type, as GET does not work with every programm. So you can just use POST instead.

aHochstein
  • 485
  • 2
  • 10