WARNING: Version 1.3 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Assertions
editAssertions
editAs many elasticsearch tests are checking for a similar output, like the amount of hits or the first hit or special highlighting, a couple of predefined assertions have been created. Those have been put into the ElasticsearchAssertions
class.
|
Checks hit count of a search or count request |
|
Ensure the a request has been acknowledged by the master |
|
Asserts a search response contains specific ids |
|
Asserts a matching count from a percolation response |
|
Asserts the first hit hits the specified matcher |
|
Asserts the second hit hits the specified matcher |
|
Asserts the third hits hits the specified matcher |
|
Assert a certain element in a search response hits the specified matcher |
|
Asserts that no shard failures have occured in the response |
|
Asserts that shard failures have happened during a search request |
|
Assert specific highlights matched |
|
Assert for specific suggestions |
|
Assert for specific suggestion count |
|
Assert a specific exception has been thrown |
Common matchers
|
Matcher to check for a search hit id |
|
Matcher to check for a search hit type |
|
Matcher to check for a search hit index |
Usually, you would combine assertions and matchers in your test like this
SearchResponse seearchResponse = client().prepareSearch() ...; assertHitCount(searchResponse, 4); assertFirstHit(searchResponse, hasId("4")); assertSearchHits(searchResponse, "1", "2", "3", "4");