当前位置: 首页>>代码示例>>Java>>正文


Java SearchSourceBuilder.from方法代码示例

本文整理汇总了Java中org.elasticsearch.search.builder.SearchSourceBuilder.from方法的典型用法代码示例。如果您正苦于以下问题:Java SearchSourceBuilder.from方法的具体用法?Java SearchSourceBuilder.from怎么用?Java SearchSourceBuilder.from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.search.builder.SearchSourceBuilder的用法示例。


在下文中一共展示了SearchSourceBuilder.from方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fullTextQuerySingleField

import org.elasticsearch.search.builder.SearchSourceBuilder; //导入方法依赖的package包/类
public String fullTextQuerySingleField(String textQuery, boolean isPhraseQuery,
				String fieldName, int start, int count) {
	QueryBuilder qb;
	if (!isPhraseQuery)
		qb = QueryBuilders.matchQuery(fieldName, textQuery);
	else
		qb = QueryBuilders.matchPhraseQuery(fieldName, textQuery);
	SearchSourceBuilder ssb = new SearchSourceBuilder();
	ssb.query(qb);
	ssb.from(start);
	if (count > -1)
		ssb.size(count);
	
	return ssb.toString();
}
 
开发者ID:topicquests,项目名称:backside-servlet-ks,代码行数:16,代码来源:ElasticQueryDSL.java

示例2: fullTextQueryMultipleFields

import org.elasticsearch.search.builder.SearchSourceBuilder; //导入方法依赖的package包/类
public String fullTextQueryMultipleFields(String textQuery, boolean isPhraseQuery,
		List<String> fieldNames, int start, int count) {
	BoolQueryBuilder qb = QueryBuilders.boolQuery();
	String fn;
	Iterator<String>itr = fieldNames.iterator();
	while (itr.hasNext()) {
		fn = itr.next();
		if (!isPhraseQuery)
			qb.should(QueryBuilders.matchQuery(fn, textQuery));
		else
			qb.should(QueryBuilders.matchPhraseQuery(fn, textQuery));
	}
	SearchSourceBuilder ssb = new SearchSourceBuilder();
	ssb.query(qb);
	ssb.from(start);
	if (count > -1)
		ssb.size(count);
	return ssb.toString();
}
 
开发者ID:topicquests,项目名称:backside-servlet-ks,代码行数:20,代码来源:ElasticQueryDSL.java

示例3: prefixTextQuerySingleField

import org.elasticsearch.search.builder.SearchSourceBuilder; //导入方法依赖的package包/类
/**
 * Return all hits which begin with <code>prefix</code>, e.g. "Wh"
 * @param prefix
 * @param fieldName
 * @param start
 * @param count
 * @return
 */
public String prefixTextQuerySingleField(String prefix, String fieldName, int start, int count) {
	QueryBuilder qb  = QueryBuilders.prefixQuery(fieldName, prefix);
	SearchSourceBuilder ssb = new SearchSourceBuilder();
	ssb.query(qb);
	ssb.from(start);
	if (count > -1)
		ssb.size(count);
	return ssb.toString();
	
}
 
开发者ID:topicquests,项目名称:backside-servlet-ks,代码行数:19,代码来源:ElasticQueryDSL.java

示例4: buildExpandSearchSourceBuilder

import org.elasticsearch.search.builder.SearchSourceBuilder; //导入方法依赖的package包/类
private SearchSourceBuilder buildExpandSearchSourceBuilder(InnerHitBuilder options) {
    SearchSourceBuilder groupSource = new SearchSourceBuilder();
    groupSource.from(options.getFrom());
    groupSource.size(options.getSize());
    if (options.getSorts() != null) {
        options.getSorts().forEach(groupSource::sort);
    }
    if (options.getFetchSourceContext() != null) {
        if (options.getFetchSourceContext().includes() == null && options.getFetchSourceContext().excludes() == null) {
            groupSource.fetchSource(options.getFetchSourceContext().fetchSource());
        } else {
            groupSource.fetchSource(options.getFetchSourceContext().includes(),
                options.getFetchSourceContext().excludes());
        }
    }
    if (options.getDocValueFields() != null) {
        options.getDocValueFields().forEach(groupSource::docValueField);
    }
    if (options.getStoredFieldsContext() != null && options.getStoredFieldsContext().fieldNames() != null) {
        options.getStoredFieldsContext().fieldNames().forEach(groupSource::storedField);
    }
    if (options.getScriptFields() != null) {
        for (SearchSourceBuilder.ScriptField field : options.getScriptFields()) {
            groupSource.scriptField(field.fieldName(), field.script());
        }
    }
    if (options.getHighlightBuilder() != null) {
        groupSource.highlighter(options.getHighlightBuilder());
    }
    groupSource.explain(options.isExplain());
    groupSource.trackScores(options.isTrackScores());
    return groupSource;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:ExpandSearchPhase.java

示例5: findByNameEntry

import org.elasticsearch.search.builder.SearchSourceBuilder; //导入方法依赖的package包/类
private ResourceDto<ESSearchResult> findByNameEntry(String nameEntry, Integer perPage, Integer page, String... indices) {

        if (nameEntry == null || nameEntry.isEmpty()) {
            throw new IllegalArgumentException("Name entry can not be null");
        }

        if (page == null) {
            page = FIRST_PAGE_NUM;
        }

        if (page <= 0) {
            throw new IllegalArgumentException("Page must be greater than zero");
        }

        if (perPage == null) {
            perPage = PER_PAGE_DEFAULT;
        }

        if (perPage <= 0) {
            throw new IllegalArgumentException("Per page value must be greater than zero");
        }

        JsonNode jsonQuery = matchQueryByName(nameEntry);
        SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
        sourceBuilder.query(QueryBuilders.wrapperQuery(jsonQuery.toString()));

        int offset = (page - 1) * perPage;
        sourceBuilder.from(offset);
        sourceBuilder.size(perPage);

        SearchRequest searchRequest = new SearchRequest(indices);
        searchRequest.source(sourceBuilder);

        ResourceDto<ESSearchResult> resultPage = new ResourceDto<>();
        try {
            SearchResponse response = client.search(searchRequest);
            JsonNode result = mapper.readTree(response.toString());

            resultPage.setResults(mapToResultList(result));
            resultPage.setPagination(getPaginationInfo(page, perPage, response.getHits().getTotalHits()));
        } catch (IOException e) {
            log.warn("Can not get ES search response. Exception: {}", e);
        }

        return resultPage;
    }
 
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:47,代码来源:ESSearchService.java

示例6: wildCardTextQuerySingleField

import org.elasticsearch.search.builder.SearchSourceBuilder; //导入方法依赖的package包/类
/**
 * <p>e.g. "W?F*HW"
 * where "?" matches any character
 * where * matches zero or more characters</p>
 * <p>Note, avoid using terms which begin with a wildcard,
 * e.g. *foo</p>
 * @param textQuery
 * @param fieldName
 * @param start
 * @param count
 * @return
 * @see https://www.elastic.co/guide/en/elasticsearch/guide/current/_wildcard_and_regexp_queries.html
 */
public String wildCardTextQuerySingleField(String textQuery, String fieldName, int start, int count) {
	QueryBuilder qb  = QueryBuilders.wildcardQuery(fieldName, textQuery);
	SearchSourceBuilder ssb = new SearchSourceBuilder();
	ssb.query(qb);
	ssb.from(start);
	if (count > -1)
		ssb.size(count);
	return ssb.toString();
}
 
开发者ID:topicquests,项目名称:backside-servlet-ks,代码行数:23,代码来源:ElasticQueryDSL.java


注:本文中的org.elasticsearch.search.builder.SearchSourceBuilder.from方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。