use of org.graylog2.indexer.searches.Searches in project graylog2-server by Graylog2.
the class SearchesIT method searchDoesNotIncludeJestMetadata.
@Test
public void searchDoesNotIncludeJestMetadata() throws Exception {
importFixture("org/graylog2/indexer/searches/SearchesIT.json");
final AbsoluteRange range = AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC).withZone(UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC).withZone(UTC));
final SearchResult searchResult = searches.search("_id:1", range, 0, 0, Sorting.DEFAULT);
assertThat(searchResult).isNotNull();
assertThat(searchResult.getTotalResults()).isEqualTo(1L);
assertThat(searchResult.getFields()).doesNotContain("es_metadata_id", "es_metadata_version");
}
use of org.graylog2.indexer.searches.Searches in project graylog2-server by Graylog2.
the class SearchesIT method fieldStatsDoesNotIncludeJestMetadata.
@Test
public void fieldStatsDoesNotIncludeJestMetadata() throws Exception {
importFixture("org/graylog2/indexer/searches/SearchesIT.json");
final AbsoluteRange range = AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC).withZone(UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC).withZone(UTC));
final FieldStatsResult fieldStatsResult = searches.fieldStats("n", "_id:1", range);
assertThat(fieldStatsResult).isNotNull();
assertThat(fieldStatsResult.searchHits()).isNotNull();
assertThat(fieldStatsResult.searchHits()).hasSize(1);
final ResultMessage resultMessage = fieldStatsResult.searchHits().get(0);
assertThat(resultMessage.getMessage().getFields()).doesNotContainKeys("es_metadata_id", "es_metadata_version");
}
use of org.graylog2.indexer.searches.Searches in project graylog2-server by Graylog2.
the class SearchesIT method testFieldStats.
@Test
public void testFieldStats() throws Exception {
importFixture("org/graylog2/indexer/searches/SearchesIT.json");
FieldStatsResult fieldStats = searches.fieldStats("n", "*", AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC)));
assertThat(fieldStats).satisfies(result -> {
assertThat(result.searchHits()).hasSize(10);
assertThat(result.count()).isEqualTo(8);
assertThat(result.min()).isEqualTo(1.0);
assertThat(result.max()).isEqualTo(4.0);
assertThat(result.mean()).isEqualTo(2.375);
assertThat(result.sum()).isEqualTo(19.0);
assertThat(result.sumOfSquares()).isEqualTo(53.0);
assertThat(result.variance()).isEqualTo(0.984375);
assertThat(result.stdDeviation()).isEqualTo(0.9921567416492215);
});
}
use of org.graylog2.indexer.searches.Searches in project graylog2-server by Graylog2.
the class SearchesIT method searchReturnsResultWithSelectiveFields.
@Test
public void searchReturnsResultWithSelectiveFields() throws Exception {
importFixture("org/graylog2/indexer/searches/SearchesIT.json");
final AbsoluteRange range = AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC).withZone(UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC).withZone(UTC));
final SearchesConfig searchesConfig = SearchesConfig.builder().query("*").range(range).limit(1).offset(0).fields(Collections.singletonList("source")).build();
final SearchResult searchResult = searches.search(searchesConfig);
assertThat(searchResult).isNotNull();
assertThat(searchResult.getResults()).hasSize(1);
assertThat(searchResult.getTotalResults()).isEqualTo(10L);
}
use of org.graylog2.indexer.searches.Searches in project graylog2-server by Graylog2.
the class SavedSearchesResource method views.
@GET
@ApiOperation("Get a list of all searches")
public PaginatedResponse<ViewSummaryDTO> views(@ApiParam(name = "page") @QueryParam("page") @DefaultValue("1") int page, @ApiParam(name = "per_page") @QueryParam("per_page") @DefaultValue("50") int perPage, @ApiParam(name = "sort", value = "The field to sort the result on", required = true, allowableValues = "id,title,created_at") @DefaultValue(ViewDTO.FIELD_TITLE) @QueryParam("sort") String sortField, @ApiParam(name = "order", value = "The sort direction", allowableValues = "asc, desc") @DefaultValue("asc") @QueryParam("order") String order, @ApiParam(name = "query") @QueryParam("query") String query, @Context SearchUser searchUser) {
if (!ViewDTO.SORT_FIELDS.contains(sortField.toLowerCase(ENGLISH))) {
sortField = ViewDTO.FIELD_TITLE;
}
try {
final SearchQuery searchQuery = searchQueryParser.parse(query);
final PaginatedList<ViewSummaryDTO> result = dbService.searchSummariesPaginatedByType(ViewDTO.Type.SEARCH, searchQuery, searchUser::canReadView, order, sortField, page, perPage);
return PaginatedResponse.create("views", result, query);
} catch (IllegalArgumentException e) {
throw new BadRequestException(e.getMessage(), e);
}
}
Aggregations