use of org.apache.metron.indexing.dao.search.SearchRequest 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.SearchRequest 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.SearchRequest 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"));
}
}
use of org.apache.metron.indexing.dao.search.SearchRequest 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"));
}
Aggregations