use of org.apache.metron.indexing.dao.search.SearchResult in project metron by apache.
the class SearchIntegrationTest method sort_by_guid.
@Test
public void sort_by_guid() throws Exception {
SearchRequest request = JSONUtils.INSTANCE.load(sortByGuidQuery, SearchRequest.class);
SearchResponse response = dao.search(request);
Assert.assertEquals(5, response.getTotal());
List<SearchResult> results = response.getResults();
for (int i = 0; i < 5; ++i) {
Map<String, Object> source = results.get(i).getSource();
Assert.assertEquals(1, source.size());
Assert.assertEquals(source.get("guid"), "bro_" + (i + 1));
}
}
use of org.apache.metron.indexing.dao.search.SearchResult in project metron by apache.
the class SearchIntegrationTest method queries_fields.
@Test
public void queries_fields() throws Exception {
SearchRequest request = JSONUtils.INSTANCE.load(fieldsQuery, SearchRequest.class);
SearchResponse response = dao.search(request);
Assert.assertEquals(10, response.getTotal());
List<SearchResult> results = response.getResults();
for (int i = 0; i < 5; ++i) {
Map<String, Object> source = results.get(i).getSource();
Assert.assertEquals(1, source.size());
Assert.assertNotNull(source.get("ip_src_addr"));
}
for (int i = 5; i < 10; ++i) {
Map<String, Object> source = results.get(i).getSource();
Assert.assertEquals(1, source.size());
Assert.assertNotNull(source.get("ip_src_addr"));
}
}
use of org.apache.metron.indexing.dao.search.SearchResult in project metron by apache.
the class SearchIntegrationTest method sort_ascending_with_missing_fields.
@Test
public void sort_ascending_with_missing_fields() throws Exception {
SearchRequest request = JSONUtils.INSTANCE.load(sortAscendingWithMissingFields, SearchRequest.class);
SearchResponse response = dao.search(request);
Assert.assertEquals(10, response.getTotal());
List<SearchResult> results = response.getResults();
Assert.assertEquals(10, results.size());
// the remaining are missing the 'threat:triage:score' and should be sorted last
for (int i = 0; i < 8; i++) {
Assert.assertFalse(results.get(i).getSource().containsKey("threat:triage:score"));
}
// validate sorted order - there are only 2 with a 'threat:triage:score'
Assert.assertEquals("10", results.get(8).getSource().get("threat:triage:score"));
Assert.assertEquals("20", results.get(9).getSource().get("threat:triage:score"));
}
use of org.apache.metron.indexing.dao.search.SearchResult in project metron by apache.
the class SearchIntegrationTest method filter_query_filters_results.
@Test
public void filter_query_filters_results() throws Exception {
SearchRequest request = JSONUtils.INSTANCE.load(filterQuery, SearchRequest.class);
SearchResponse response = dao.search(request);
Assert.assertEquals(3, response.getTotal());
List<SearchResult> results = response.getResults();
Assert.assertEquals("snort", results.get(0).getSource().get("source:type"));
Assert.assertEquals(9, results.get(0).getSource().get("timestamp"));
Assert.assertEquals("snort", results.get(1).getSource().get("source:type"));
Assert.assertEquals(7, results.get(1).getSource().get("timestamp"));
Assert.assertEquals("bro", results.get(2).getSource().get("source:type"));
Assert.assertEquals(1, results.get(2).getSource().get("timestamp"));
}
use of org.apache.metron.indexing.dao.search.SearchResult in project metron by apache.
the class SearchIntegrationTest method all_query_returns_all_results.
@Test
public void all_query_returns_all_results() throws Exception {
SearchRequest request = JSONUtils.INSTANCE.load(allQuery, SearchRequest.class);
SearchResponse response = dao.search(request);
Assert.assertEquals(10, response.getTotal());
List<SearchResult> results = response.getResults();
Assert.assertEquals(10, results.size());
for (int i = 0; i < 5; ++i) {
Assert.assertEquals("snort", results.get(i).getSource().get("source:type"));
Assert.assertEquals(10 - i, results.get(i).getSource().get("timestamp"));
}
for (int i = 5; i < 10; ++i) {
Assert.assertEquals("bro", results.get(i).getSource().get("source:type"));
Assert.assertEquals(10 - i, results.get(i).getSource().get("timestamp"));
}
}
Aggregations