本文整理匯總了Java中org.elasticsearch.index.query.RangeQueryBuilder.lte方法的典型用法代碼示例。如果您正苦於以下問題:Java RangeQueryBuilder.lte方法的具體用法?Java RangeQueryBuilder.lte怎麽用?Java RangeQueryBuilder.lte使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.index.query.RangeQueryBuilder
的用法示例。
在下文中一共展示了RangeQueryBuilder.lte方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createRangeQuery
import org.elasticsearch.index.query.RangeQueryBuilder; //導入方法依賴的package包/類
private static RangeQueryBuilder createRangeQuery(String name, Map<String, Object> rangeOperation,
Float boost) {
RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(name+RAW_APPEND);
for (Map.Entry<String, Object> it : rangeOperation.entrySet()) {
if (it.getKey().equalsIgnoreCase(LTE)) {
rangeQueryBuilder.lte(it.getValue());
} else if (it.getKey().equalsIgnoreCase(LT)) {
rangeQueryBuilder.lt(it.getValue());
} else if (it.getKey().equalsIgnoreCase(GTE)) {
rangeQueryBuilder.gte(it.getValue());
} else if (it.getKey().equalsIgnoreCase(GT)) {
rangeQueryBuilder.gt(it.getValue());
}
}
if (isNotNull(boost)) {
return rangeQueryBuilder.boost(boost);
}
return rangeQueryBuilder;
}
示例2: range
import org.elasticsearch.index.query.RangeQueryBuilder; //導入方法依賴的package包/類
/**
* @param operator operator <,>,<=,>=
* @param field field name
* @param stringValue field value
* @return a range query
*/
static QueryBuilder range(String operator, String field, String stringValue) {
String key = StringUtils.replaceAll(field, "[<>=\\s]+$", "");
boolean nestedMode = nestedMode() && field.startsWith(PROPS_PREFIX);
RangeQueryBuilder rfb = rangeQuery(nestedMode ? getValueFieldName(stringValue) : key);
if (">".equals(operator)) {
rfb.gt(getNumericValue(stringValue));
} else if ("<".equals(operator)) {
rfb.lt(getNumericValue(stringValue));
} else if (">=".equals(operator)) {
rfb.gte(getNumericValue(stringValue));
} else if ("<=".equals(operator)) {
rfb.lte(getNumericValue(stringValue));
}
if (nestedMode) {
return nestedPropsQuery(keyValueBoolQuery(key, stringValue, rfb));
} else {
return rfb;
}
}
示例3: adaptRequestBuilder
import org.elasticsearch.index.query.RangeQueryBuilder; //導入方法依賴的package包/類
@Override
protected SearchRequestBuilder adaptRequestBuilder(final Client esClient,
final SearchRequestBuilder requestBuilder) {
QueryBuilder filter = null;
if (from != null || to != null) {
final RangeQueryBuilder occRange = QueryBuilders.rangeQuery(Event.FIELD_TIMESTAMP);
if (from != null) {
occRange.gte(from.getTime());
}
if (to != null) {
occRange.lte(to.getTime());
}
filter = occRange;
}
if (filter != null) {
requestBuilder.setQuery(filter);
}
return requestBuilder;
}
示例4: convert
import org.elasticsearch.index.query.RangeQueryBuilder; //導入方法依賴的package包/類
@Override
public QueryBuilder convert(Filter filter) {
String field = filter.getString("field");
if (field == null) {
field = filter.getName();
}
RangeQueryBuilder result = rangeQuery(field);
String gte = filter.getString("gte");
String gt = filter.getString("gt");
String lt = filter.getString("lt");
String lte = filter.getString("lte");
String time_zone = filter.getString("time_zone");
if (gte != null) {
result.gte(gte);
}
if (gt != null) {
result.gt(gt);
}
if (lt != null) {
result.lt(lt);
}
if (lte != null) {
result.lte(lte);
}
if (time_zone != null) {
result.timeZone(time_zone);
}
return result;
}
示例5: getTraces
import org.elasticsearch.index.query.RangeQueryBuilder; //導入方法依賴的package包/類
@Override public ListenableFuture<List<List<Span>>> getTraces(QueryRequest request) {
long endMillis = request.endTs;
long beginMillis = endMillis - request.lookback;
BoolQueryBuilder filter = boolQuery()
.must(rangeQuery("timestamp_millis")
.gte(beginMillis)
.lte(endMillis));
if (request.serviceName != null) {
filter.must(boolQuery()
.should(nestedQuery(
"annotations", termQuery("annotations.endpoint.serviceName", request.serviceName)))
.should(nestedQuery(
"binaryAnnotations",
termQuery("binaryAnnotations.endpoint.serviceName", request.serviceName))));
}
if (request.spanName != null) {
filter.must(termQuery("name", request.spanName));
}
for (String annotation : request.annotations) {
BoolQueryBuilder annotationQuery = boolQuery()
.must(termQuery("annotations.value", annotation));
if (request.serviceName != null) {
annotationQuery.must(termQuery("annotations.endpoint.serviceName", request.serviceName));
}
filter.must(nestedQuery("annotations", annotationQuery));
}
for (Map.Entry<String, String> kv : request.binaryAnnotations.entrySet()) {
// In our index template, we make sure the binaryAnnotation value is indexed as string,
// meaning non-string values won't even be indexed at all. This means that we can only
// match string values here, which happens to be exactly what we want.
BoolQueryBuilder binaryAnnotationQuery = boolQuery()
.must(termQuery("binaryAnnotations.key", kv.getKey()))
.must(termQuery("binaryAnnotations.value", kv.getValue()));
if (request.serviceName != null) {
binaryAnnotationQuery.must(
termQuery("binaryAnnotations.endpoint.serviceName", request.serviceName));
}
filter.must(nestedQuery("binaryAnnotations", binaryAnnotationQuery));
}
if (request.minDuration != null) {
RangeQueryBuilder durationQuery = rangeQuery("duration").gte(request.minDuration);
if (request.maxDuration != null) {
durationQuery.lte(request.maxDuration);
}
filter.must(durationQuery);
}
Set<String> strings = indexNameFormatter.indexNamePatternsForRange(beginMillis, endMillis);
final String[] indices = strings.toArray(new String[0]);
// We need to filter to traces that contain at least one span that matches the request,
// but the zipkin API is supposed to order traces by first span, regardless of if it was
// filtered or not. This is not possible without either multiple, heavyweight queries
// or complex multiple indexing, defeating much of the elegance of using elasticsearch for this.
// So we fudge and order on the first span among the filtered spans - in practice, there should
// be no significant difference in user experience since span start times are usually very
// close to each other in human time.
ListenableFuture<List<String>> traceIds =
client.collectBucketKeys(indices,
boolQuery().must(matchAllQuery()).filter(filter),
AggregationBuilders.terms("traceId_agg")
.field("traceId")
.subAggregation(AggregationBuilders.min("timestamps_agg")
.field("timestamp_millis"))
.order(Order.aggregation("timestamps_agg", false))
.size(request.limit));
return transform(traceIds, new AsyncFunction<List<String>, List<List<Span>>>() {
@Override public ListenableFuture<List<List<Span>>> apply(List<String> input) {
return getTracesByIds(input, indices);
}
}
);
}
示例6: loadTop
import org.elasticsearch.index.query.RangeQueryBuilder; //導入方法依賴的package包/類
@Override public JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName,
Error error, int applicationId, List<String> segmentIds, int limit, int from, Sort sort) {
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(SegmentCostTable.TABLE);
searchRequestBuilder.setTypes(SegmentCostTable.TABLE_TYPE);
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
searchRequestBuilder.setQuery(boolQueryBuilder);
List<QueryBuilder> mustQueryList = boolQueryBuilder.must();
mustQueryList.add(QueryBuilders.rangeQuery(SegmentCostTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime));
if (minCost != -1 || maxCost != -1) {
RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(SegmentCostTable.COLUMN_COST);
if (minCost != -1) {
rangeQueryBuilder.gte(minCost);
}
if (maxCost != -1) {
rangeQueryBuilder.lte(maxCost);
}
boolQueryBuilder.must().add(rangeQueryBuilder);
}
if (StringUtils.isNotEmpty(operationName)) {
mustQueryList.add(QueryBuilders.matchQuery(SegmentCostTable.COLUMN_SERVICE_NAME, operationName));
}
if (CollectionUtils.isNotEmpty(segmentIds)) {
boolQueryBuilder.must().add(QueryBuilders.termsQuery(SegmentCostTable.COLUMN_SEGMENT_ID, segmentIds.toArray(new String[0])));
}
if (Error.True.equals(error)) {
boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_IS_ERROR, true));
} else if (Error.False.equals(error)) {
boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_IS_ERROR, false));
}
if (applicationId != 0) {
boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_APPLICATION_ID, applicationId));
}
if (Sort.Cost.equals(sort)) {
searchRequestBuilder.addSort(SegmentCostTable.COLUMN_COST, SortOrder.DESC);
} else if (Sort.Time.equals(sort)) {
searchRequestBuilder.addSort(SegmentCostTable.COLUMN_START_TIME, SortOrder.DESC);
}
searchRequestBuilder.setSize(limit);
searchRequestBuilder.setFrom(from);
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
JsonObject topSegPaging = new JsonObject();
topSegPaging.addProperty("recordsTotal", searchResponse.getHits().totalHits);
JsonArray topSegArray = new JsonArray();
topSegPaging.add("data", topSegArray);
int num = from;
for (SearchHit searchHit : searchResponse.getHits().getHits()) {
JsonObject topSegmentJson = new JsonObject();
topSegmentJson.addProperty("num", num);
String segmentId = (String)searchHit.getSource().get(SegmentCostTable.COLUMN_SEGMENT_ID);
topSegmentJson.addProperty(SegmentCostTable.COLUMN_SEGMENT_ID, segmentId);
topSegmentJson.addProperty(SegmentCostTable.COLUMN_START_TIME, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_START_TIME));
if (searchHit.getSource().containsKey(SegmentCostTable.COLUMN_END_TIME)) {
topSegmentJson.addProperty(SegmentCostTable.COLUMN_END_TIME, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_END_TIME));
}
topSegmentJson.addProperty(SegmentCostTable.COLUMN_APPLICATION_ID, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_APPLICATION_ID));
topSegmentJson.addProperty(SegmentCostTable.COLUMN_SERVICE_NAME, (String)searchHit.getSource().get(SegmentCostTable.COLUMN_SERVICE_NAME));
topSegmentJson.addProperty(SegmentCostTable.COLUMN_COST, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_COST));
topSegmentJson.addProperty(SegmentCostTable.COLUMN_IS_ERROR, (Boolean)searchHit.getSource().get(SegmentCostTable.COLUMN_IS_ERROR));
num++;
topSegArray.add(topSegmentJson);
}
return topSegPaging;
}