-
This unit test will search document with term aggregation:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"match_all":{}}, "size": 0,"aggs": {"my-agg-term": {"terms": {"field": "City"}}}}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.GreaterorEqual to check length of aggreagation data is greater or equal to 1.
-
This unit test will search document with metric aggregation:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"match_all":{}}, "size": 0,"aggs": {"my-agg-max": {"max": {"field": "Year"}},"my-agg-min": {"min": {"field": "Year"}},"my-agg-avg": {"avg": {"field": "Year"}}}}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.GreaterorEqual to check length of aggreagation data is greater or equal to 1.