use of org.opensearch.test.hamcrest.OpenSearchAssertions.assertSearchResponse in project OpenSearch by opensearch-project.
the class MoreExpressionIT method testSparseField.
public void testSparseField() throws Exception {
OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "x", "type=long", "y", "type=long"));
ensureGreen("test");
indexRandom(true, client().prepareIndex("test").setId("1").setSource("id", 1, "x", 4), client().prepareIndex("test").setId("2").setSource("id", 2, "y", 2));
SearchResponse rsp = buildRequest("doc['x'] + 1").get();
OpenSearchAssertions.assertSearchResponse(rsp);
SearchHits hits = rsp.getHits();
assertEquals(2, rsp.getHits().getTotalHits().value);
assertEquals(5.0, hits.getAt(0).field("foo").getValue(), 0.0D);
assertEquals(1.0, hits.getAt(1).field("foo").getValue(), 0.0D);
}
Aggregations