Examples of TermsResult


Examples of org.graylog2.indexer.results.TermsResult

        srb.addFacet(terms);

        final SearchRequest request = srb.request();
        SearchResponse r = c.search(request).actionGet();

        return new TermsResult(
                (TermsFacet) r.getFacets().facet(TERMS_FACET_NAME),
                query,
                request.source(),
                r.getTook()
        );
View Full Code Here

Examples of org.graylog2.indexer.results.TermsResult

    @Produces(MediaType.APPLICATION_JSON)
    public String list(
            @ApiParam(name = "range", value = "Relative timeframe to search in. See method description.", required = true)
            @QueryParam("range")
            final int range) {
        TermsResult sources;
        try {
            sources = cache.get(CACHE_KEY + range, new Callable<TermsResult>() {
                @Override
                public TermsResult call() throws Exception {
                    try {
                        return searches.terms("source", 5000, "*", new RelativeRange(range));
                    } catch (IndexHelper.InvalidRangeFormatException e) {
                        throw new ExecutionException(e);
                    } catch (InvalidRangeParametersException e) {
                        throw new ExecutionException(e);
                    }
                }
            });
        } catch (ExecutionException e) {
            if (e.getCause() instanceof InvalidRangeParametersException) {
                LOG.error("Invalid relative time range value.", e);
                throw new BadRequestException("Invalid time range " + range);
            } else {
                LOG.error("Could not calculate list of sources.", e);
                throw new WebApplicationException(500);
            }
        }

        Map<String, Object> result = Maps.newHashMap();
        result.put("total", sources.getTerms().size());
        result.put("sources", sources.getTerms());
        result.put("took_ms", sources.took().millis());
        result.put("range", range);

        return json(result);
    }
View Full Code Here

Examples of org.graylog2.indexer.results.TermsResult

        if (!isNullOrEmpty(streamId)) {
            filter = "streams:" + streamId;
        }

        try {
            final TermsResult terms = searches.terms(field, 50, query, filter, timeRange);

            Map<String, Object> result = Maps.newHashMap();
            result.put("terms", terms.getTerms());
            result.put("total", terms.getTotal());
            result.put("other", terms.getOther());
            result.put("missing", terms.getMissing());

            return new ComputationResult(result, terms.took().millis());
        } catch (IndexHelper.InvalidRangeFormatException e) {
            String msg = "Could not calculate [" + this.getClass().getCanonicalName() + "] widget <" + getId() + ">. Invalid time range.";
            LOG.error(msg, e);
            throw new RuntimeException(msg);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.