Search in sources :

Example 21 with SearchResponse

use of org.apache.metron.indexing.dao.search.SearchResponse 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

SearchResponse (org.apache.metron.indexing.dao.search.SearchResponse)21 SearchRequest (org.apache.metron.indexing.dao.search.SearchRequest)18 Test (org.junit.Test)17 SearchResult (org.apache.metron.indexing.dao.search.SearchResult)14 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 SortField (org.apache.metron.indexing.dao.search.SortField)5 Map (java.util.Map)4 GetRequest (org.apache.metron.indexing.dao.search.GetRequest)4 InvalidSearchException (org.apache.metron.indexing.dao.search.InvalidSearchException)4 IOException (java.io.IOException)2 ElasticsearchDao (org.apache.metron.elasticsearch.dao.ElasticsearchDao)2 MetaAlertCreateResponse (org.apache.metron.indexing.dao.metaalert.MetaAlertCreateResponse)2 JSONArray (org.json.simple.JSONArray)2 JSONObject (org.json.simple.JSONObject)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Joiner (com.google.common.base.Joiner)1 Iterables (com.google.common.collect.Iterables)1 File (java.io.File)1 SimpleDateFormat (java.text.SimpleDateFormat)1