Search in sources :

Example 6 with QueryStringQueryBuilder

use of org.elasticsearch.index.query.QueryStringQueryBuilder in project graylog2-server by Graylog2.

the class Searches method histogram.

public HistogramResult histogram(String query, DateHistogramInterval interval, String filter, TimeRange range) {
    FilterAggregationBuilder builder = AggregationBuilders.filter(AGG_FILTER).subAggregation(AggregationBuilders.dateHistogram(AGG_HISTOGRAM).field("timestamp").interval(interval.toESInterval())).filter(standardAggregationFilters(range, filter));
    QueryStringQueryBuilder qs = queryStringQuery(query);
    qs.allowLeadingWildcard(configuration.isAllowLeadingWildcardSearches());
    final Set<String> affectedIndices = determineAffectedIndices(range, filter);
    final SearchRequestBuilder srb = c.prepareSearch(affectedIndices.toArray(new String[affectedIndices.size()])).setIndicesOptions(IndicesOptions.lenientExpandOpen()).setQuery(qs).addAggregation(builder);
    final SearchRequest request = srb.request();
    SearchResponse r = c.search(request).actionGet();
    recordEsMetrics(r, range);
    final Filter f = r.getAggregations().get(AGG_FILTER);
    return new DateHistogramResult(f.getAggregations().get(AGG_HISTOGRAM), query, request.source(), interval, r.getTook());
}
Also used : SearchRequest(org.elasticsearch.action.search.SearchRequest) DateHistogramResult(org.graylog2.indexer.results.DateHistogramResult) FilterAggregationBuilder(org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder) SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) Filter(org.elasticsearch.search.aggregations.bucket.filter.Filter) QueryStringQueryBuilder(org.elasticsearch.index.query.QueryStringQueryBuilder) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Example 7 with QueryStringQueryBuilder

use of org.elasticsearch.index.query.QueryStringQueryBuilder in project fess by codelibs.

the class EsAbstractConditionQuery method doQueryString.

protected void doQueryString(String queryString, ConditionOptionCall<QueryStringQueryBuilder> opLambda) {
    QueryStringQueryBuilder queryStringQuery = QueryBuilders.queryStringQuery(queryString);
    regQ(queryStringQuery);
    if (opLambda != null) {
        opLambda.callback(queryStringQuery);
    }
}
Also used : QueryStringQueryBuilder(org.elasticsearch.index.query.QueryStringQueryBuilder)

Aggregations

QueryStringQueryBuilder (org.elasticsearch.index.query.QueryStringQueryBuilder)7 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)3 SearchResponse (org.elasticsearch.action.search.SearchResponse)3 Filter (org.elasticsearch.search.aggregations.bucket.filter.Filter)3 SearchRequest (org.elasticsearch.action.search.SearchRequest)2 FilterAggregationBuilder (org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder)2 AuthorisationException (com.atlassian.stash.exception.AuthorisationException)1 Repository (com.atlassian.stash.repository.Repository)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 GlobalSettings (com.palantir.stash.codesearch.admin.GlobalSettings)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ServletException (javax.servlet.ServletException)1 SearchPhaseExecutionException (org.elasticsearch.action.search.SearchPhaseExecutionException)1 ShardSearchFailure (org.elasticsearch.action.search.ShardSearchFailure)1 TimeValue (org.elasticsearch.common.unit.TimeValue)1 FilterBuilder (org.elasticsearch.index.query.FilterBuilder)1 FilterBuilders.andFilter (org.elasticsearch.index.query.FilterBuilders.andFilter)1 FilterBuilders.boolFilter (org.elasticsearch.index.query.FilterBuilders.boolFilter)1