q.field(keyProperty).notEqual(keyValue);
/** * Creates a descending list of metrics for a specified period of time. * * @param id Trace field wanted * @param size max number of elements to return * @param period period of time wanted * @return List of metrics */ public List<Metric> findByTop(String id, int size, Periods period) { final Datastore datastore = this.datastore(); Query<LogTrace> query = prepareRange(datastore.createQuery(LogTrace.class), period); query.field(id).notEqual(null); final AggregationPipeline pipeline = datastore.createAggregation(LogTrace.class) .match(query) .group(id, Group.grouping("metric", Group.last(id)), Group.grouping("value", Accumulator.accumulator("$sum", 1))) .sort(Sort.descending("value")) .limit(size); final Iterator<Metric> aggregate = pipeline.aggregate(Metric.class); List<Metric> list = new ArrayList<>(); aggregate.forEachRemaining(list::add); return list; }
query.field(filtersDTO.getName()).notEqual(value1); break;