use of org.apache.metron.indexing.dao.search.SearchRequest in project metron by apache.
the class SearchIntegrationTest method sort_descending_with_missing_fields.
@Test
public void sort_descending_with_missing_fields() throws Exception {
SearchRequest request = JSONUtils.INSTANCE.load(sortDescendingWithMissingFields, SearchRequest.class);
SearchResponse response = dao.search(request);
Assert.assertEquals(10, response.getTotal());
List<SearchResult> results = response.getResults();
Assert.assertEquals(10, results.size());
// validate sorted order - there are only 2 with a 'threat:triage:score'
Assert.assertEquals("20", results.get(0).getSource().get("threat:triage:score"));
Assert.assertEquals("10", results.get(1).getSource().get("threat:triage:score"));
// the remaining are missing the 'threat:triage:score' and should be sorted last
for (int i = 2; i < 10; i++) {
Assert.assertFalse(results.get(i).getSource().containsKey("threat:triage:score"));
}
}
use of org.apache.metron.indexing.dao.search.SearchRequest in project metron by apache.
the class SearchIntegrationTest method exceeding_max_resulsts_throws_exception.
@Test
public void exceeding_max_resulsts_throws_exception() throws Exception {
thrown.expect(InvalidSearchException.class);
thrown.expectMessage("Search result size must be less than 100");
SearchRequest request = JSONUtils.INSTANCE.load(exceededMaxResultsQuery, SearchRequest.class);
dao.search(request);
}
use of org.apache.metron.indexing.dao.search.SearchRequest in project metron by apache.
the class SearchIntegrationTest method bad_facet_query_throws_exception.
@Test
public void bad_facet_query_throws_exception() throws Exception {
thrown.expect(InvalidSearchException.class);
thrown.expectMessage("Failed to execute search");
SearchRequest request = JSONUtils.INSTANCE.load(badFacetQuery, SearchRequest.class);
dao.search(request);
}
use of org.apache.metron.indexing.dao.search.SearchRequest in project metron by apache.
the class SearchIntegrationTest method no_results_returned_when_query_does_not_match.
@Test
public void no_results_returned_when_query_does_not_match() throws Exception {
SearchRequest request = JSONUtils.INSTANCE.load(noResultsFieldsQuery, SearchRequest.class);
SearchResponse response = dao.search(request);
Assert.assertEquals(0, response.getTotal());
}
use of org.apache.metron.indexing.dao.search.SearchRequest in project metron by apache.
the class SearchServiceImplTest method searchShouldProperlySearchWithEmptyDefaultFacetFields.
@Test
public void searchShouldProperlySearchWithEmptyDefaultFacetFields() throws Exception {
when(environment.getProperty(SEARCH_FACET_FIELDS_SPRING_PROPERTY, String.class, "")).thenReturn("");
SearchRequest searchRequest = new SearchRequest();
searchRequest.setIndices(Arrays.asList("bro", "snort", "metaalert"));
searchService.search(searchRequest);
SearchRequest expectedSearchRequest = new SearchRequest();
expectedSearchRequest.setIndices(Arrays.asList("bro", "snort", "metaalert"));
verify(dao).search(eq(expectedSearchRequest));
}
Aggregations