1
votes

I've been executing this GET against Elasticsearch:

http://localhost:9200/_search?q=test

It works. But what is the equivalent of this in the Query language?

All of the examples in the documentation look like this:

GET /twitter/_search
{
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}

but I don't want to identify what the value is (the user JSON label, in this case). I just want to do a full search across everything. When I tried doing:

GET /_search
{
    "query" : {
        "term" : "test"
    }
}

I get query malformed, no start_object after query name.

I just want the request body equivalent of the ?q=test. What is it?

1

1 Answers

2
votes

The equivalent query of ?q=test is using the query_string query, like this:

GET /twitter/_search
{
    "query" : {
        "query_string" : { 
            "query" : "test" 
        }
    }
}