This commit adds initial support for Count requests, which are simple
search requests asking to get the number of matches for a query.
The functionality is provided by the Count() function, which accepts a
query object (implementing the Mappable interface), and can be executed
just like a search request.
res, err := esquery.
Count(esquery.Match("user", "someone")).
Run(es)
18 lines
280 B
Go
18 lines
280 B
Go
package esquery
|
|
|
|
import "testing"
|
|
|
|
func TestCount(t *testing.T) {
|
|
runMapTests(t, []mapTest{
|
|
{
|
|
"a simple count request",
|
|
Count(MatchAll()),
|
|
map[string]interface{}{
|
|
"query": map[string]interface{}{
|
|
"match_all": map[string]interface{}{},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
}
|