Search in sources :

Example 16 with SearchResult

use of org.apache.metron.indexing.dao.search.SearchResult in project metron by apache.

the class SearchIntegrationTest method results_are_paginated.

@Test
public void results_are_paginated() throws Exception {
    SearchRequest request = JSONUtils.INSTANCE.load(paginationQuery, SearchRequest.class);
    SearchResponse response = dao.search(request);
    Assert.assertEquals(10, response.getTotal());
    List<SearchResult> results = response.getResults();
    Assert.assertEquals(3, results.size());
    Assert.assertEquals("snort", results.get(0).getSource().get("source:type"));
    Assert.assertEquals(6, results.get(0).getSource().get("timestamp"));
    Assert.assertEquals("bro", results.get(1).getSource().get("source:type"));
    Assert.assertEquals(5, results.get(1).getSource().get("timestamp"));
    Assert.assertEquals("bro", results.get(2).getSource().get("source:type"));
    Assert.assertEquals(4, results.get(2).getSource().get("timestamp"));
}
Also used : SearchRequest(org.apache.metron.indexing.dao.search.SearchRequest) SearchResult(org.apache.metron.indexing.dao.search.SearchResult) SearchResponse(org.apache.metron.indexing.dao.search.SearchResponse) Test(org.junit.Test)

Aggregations

SearchResult (org.apache.metron.indexing.dao.search.SearchResult)16 SearchResponse (org.apache.metron.indexing.dao.search.SearchResponse)15 SearchRequest (org.apache.metron.indexing.dao.search.SearchRequest)12 Test (org.junit.Test)10 InvalidSearchException (org.apache.metron.indexing.dao.search.InvalidSearchException)5 ArrayList (java.util.ArrayList)4 IOException (java.io.IOException)3 MetaAlertCreateResponse (org.apache.metron.indexing.dao.metaalert.MetaAlertCreateResponse)3 GetRequest (org.apache.metron.indexing.dao.search.GetRequest)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Constants (org.apache.metron.common.Constants)2 AccessConfig (org.apache.metron.indexing.dao.AccessConfig)2 IndexDao (org.apache.metron.indexing.dao.IndexDao)2 MetaAlertDao (org.apache.metron.indexing.dao.MetaAlertDao)2 MetaAlertCreateRequest (org.apache.metron.indexing.dao.metaalert.MetaAlertCreateRequest)2 MetaAlertStatus (org.apache.metron.indexing.dao.metaalert.MetaAlertStatus)2 FieldType (org.apache.metron.indexing.dao.search.FieldType)2 GroupRequest (org.apache.metron.indexing.dao.search.GroupRequest)2