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


Java SearchRequestBuilder.setTypes方法代码示例

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


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

示例1: deleteAllTest

import org.elasticsearch.action.search.SearchRequestBuilder; //导入方法依赖的package包/类
@Test
public void deleteAllTest() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
	delete(String.format("DELETE FROM %s/account_temp", TEST_INDEX));

	// Assert no results exist for this type.
	SearchRequestBuilder request = MainTestSuite.getClient().prepareSearch(TEST_INDEX);
	request.setTypes("account_temp");
	SearchResponse response = request.setQuery(QueryBuilders.matchAllQuery()).get();
	assertThat(response.getHits().getTotalHits(), equalTo(0L));
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:11,代码来源:DeleteTest.java

示例2: deleteWithConditionTest

import org.elasticsearch.action.search.SearchRequestBuilder; //导入方法依赖的package包/类
@Test
public void deleteWithConditionTest() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
	delete(String.format("DELETE FROM %s/phrase WHERE phrase = 'quick fox here' ", TEST_INDEX));
	// Assert no results exist for this type.
	SearchRequestBuilder request = MainTestSuite.getClient().prepareSearch(TEST_INDEX);
	request.setTypes("phrase");
	SearchResponse response = request.setQuery(QueryBuilders.matchAllQuery()).get();
	assertThat(response.getHits().getTotalHits(), equalTo(3L));
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:10,代码来源:DeleteTest.java

示例3: buildSearchRequest

import org.elasticsearch.action.search.SearchRequestBuilder; //导入方法依赖的package包/类
private SearchRequestBuilder buildSearchRequest (EsQueryDo esQueryObj) throws  EsException {
    if (Check.NuNStrStrict(esClientFactory.getIndexs(esQueryObj.getIndexName()))) {
        throw new EsException("没有指定要搜索的索引名称(indexName)");
    }
    for (ThreadPoolStats.Stats stats : esClientFactory.getClient().threadPool().stats()) {
        logger.info(JSON.toJSONString(stats));
    }
    //加载要搜索索引
    SearchRequestBuilder searchRequestBuilder = esClientFactory.getClient().prepareSearch(esClientFactory.getIndexs(esQueryObj.getIndexName()));
    //由spring从配置加载要搜索的index的类型
    searchRequestBuilder.setTypes(esQueryObj.getTypeName());
    //由spring从配置加载要搜索的类型
    searchRequestBuilder.setSearchType(SearchType.fromId(esQueryObj.getSearchType()));
    //查询可以为null
    searchRequestBuilder.setQuery(esQueryObj.getQueryBuilder());

    if (!Check.NuNCollection(esQueryObj.getSortBuilders())) {
        for (SortBuilder sortBuilder : esQueryObj.getSortBuilders()) {
            searchRequestBuilder.addSort(sortBuilder);
        }
    }
    if (!Check.NuNCollection(esQueryObj.getAggregationBuilders())) {
        for (AbstractAggregationBuilder aggregationBuilder : esQueryObj.getAggregationBuilders()) {
            searchRequestBuilder.addAggregation(aggregationBuilder);
        }

    }
    //设置高亮域
   if (esQueryObj.isHighLigth()) {
        if (!Check.NuNObject(esQueryObj.highLigthFields())) {
            for (String hlFieldName : esQueryObj.highLigthFields()) {
                searchRequestBuilder.addHighlightedField(hlFieldName).setHighlighterPreTags(esQueryObj.getHighLigthPreTag())
                        .setHighlighterPostTags(esQueryObj.getHighLigthPostTag());
            }
        }
    }
    //分页
    searchRequestBuilder.setFrom(esQueryObj.getFromIndex()).setSize(esQueryObj.getSize());
    searchRequestBuilder.setExplain(esQueryObj.isExplain());
    return searchRequestBuilder;
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:42,代码来源:EsQuery.java


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