當前位置: 首頁>>代碼示例>>Java>>正文


Java RangeQueryBuilder.from方法代碼示例

本文整理匯總了Java中org.elasticsearch.index.query.RangeQueryBuilder.from方法的典型用法代碼示例。如果您正苦於以下問題:Java RangeQueryBuilder.from方法的具體用法?Java RangeQueryBuilder.from怎麽用?Java RangeQueryBuilder.from使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.index.query.RangeQueryBuilder的用法示例。


在下文中一共展示了RangeQueryBuilder.from方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAll

import org.elasticsearch.index.query.RangeQueryBuilder; //導入方法依賴的package包/類
public Map<String, List<EborpSample>> getAll(String timeRange) {
		//TODO datumrange toevoegen
		SearchRequestBuilder search = client.prepareSearch(INDEX_NAME);

		RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery("epoch");
		rangeQuery.from("now-" + timeRange);

		SearchRequestBuilder srb = search.setQuery(rangeQuery);
		srb.setSize(1000000);

        final SearchResponse response = srb.execute().actionGet();

//        final Map<String, List<Triplet<Integer, Instant, String>>> results = new HashMap<>();
//		System.out.println("response.getHits().hits() = " + response.getHits().hits().length);

		return Arrays.asList(response.getHits().hits()).stream()
				.map(SearchHit::getSource)
				.map(this::mapToEborpSample)
				.collect(Collectors.groupingBy(EborpSample::getMac));
    }
 
開發者ID:royvanrijn,項目名稱:eborp,代碼行數:21,代碼來源:ElasticsearchClient.java

示例2: mergeQueryParts

import org.elasticsearch.index.query.RangeQueryBuilder; //導入方法依賴的package包/類
/**
 * Provides a convenience method to merge two query parts together. Assuming that the value of
 * {@link #canMergeQueryParts(QueryBuilder, QueryBuilder, ConditionType)} is {@code true}, this method will attempt
 * to take the values out of the current query part and put them into the appropriate fields in the previous query part.
 *
 * @param previousPart The previous query part to merge into.
 * @param part         The current query part to merge into the previous.
 * @see #canMergeQueryParts(QueryBuilder, QueryBuilder, ConditionType)
 */
void mergeQueryParts(final QueryBuilder previousPart, final QueryBuilder part) {
    final RangeQueryBuilder previousRangeQuery = (RangeQueryBuilder) previousPart;
    final RangeQueryBuilder currentRangeQuery = (RangeQueryBuilder) part;

    // If the "from" field is filled in, we know we're greater than/greater than or equal to.
    if (null == currentRangeQuery.to()) {
        previousRangeQuery.from(currentRangeQuery.from());
        previousRangeQuery.includeLower(currentRangeQuery.includeLower());
    } else {
        // Otherwise we're less than/less than or equal to.
        previousRangeQuery.to(currentRangeQuery.to());
        previousRangeQuery.includeUpper(currentRangeQuery.includeUpper());
    }
}
 
開發者ID:8x8Cloud,項目名稱:fiql-elasticsearch,代碼行數:24,代碼來源:ElasticsearchQueryBuilderVisitor.java

示例3: query

import org.elasticsearch.index.query.RangeQueryBuilder; //導入方法依賴的package包/類
@Override
    public Object query(Person person) {
        List<Map<String, Object>> result = new ArrayList<>();
        try {
            BoolQueryBuilder boolBuilder = QueryBuilders.boolQuery();
            if (person.getName() != null) {
//	            boolBuilder.must(QueryBuilders.matchQuery("name", person.getName()));
                boolBuilder.should(QueryBuilders.matchQuery("name", person.getName()));
            }
            if (person.getIntroduce() != null) {
//	            boolBuilder.must(QueryBuilders.matchQuery("introduce", person.getIntroduce()));
                boolBuilder.should(QueryBuilders.matchQuery("introduce", person.getIntroduce()));
            }

            //大於age,小於age+10
            if (person.getAge() > 0) {
                RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery("age");
                rangeQuery.from(person.getAge());
                rangeQuery.to(person.getAge() + 10);
                boolBuilder.filter(rangeQuery);
            }
            SearchRequestBuilder builder = transportClient.prepareSearch(index)
                    .setTypes(type)
                    .setSearchType(SearchType.QUERY_THEN_FETCH)
                    .setQuery(boolBuilder)
                    .setFrom(0)
                    .setSize(10);
            log.info(String.valueOf(builder));
            SearchResponse response = builder.get();
            response.getHits().forEach((s) -> result.add(s.getSource()));
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage(), e);
        }
        return result;
    }
 
開發者ID:jeikerxiao,項目名稱:SpringBootStudy,代碼行數:37,代碼來源:PersonDaoImpl.java

示例4: addRangeTerm

import org.elasticsearch.index.query.RangeQueryBuilder; //導入方法依賴的package包/類
@Override
public void addRangeTerm(String field, String startValue, String endValue) {
    RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(field);
    if (!startValue.equals("*")) {
        rangeQueryBuilder = rangeQueryBuilder.from(startValue);
    }
    if (!endValue.equals("*")) {
        rangeQueryBuilder = rangeQueryBuilder.to(endValue);
    }
    _boolQueryBuilder = _boolQueryBuilder.should(rangeQueryBuilder);
}
 
開發者ID:R-Knowsys,項目名稱:elasticray,代碼行數:12,代碼來源:BooleanQueryImpl.java


注:本文中的org.elasticsearch.index.query.RangeQueryBuilder.from方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。