• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MultiSearchRequestBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



MultiSearchRequestBuilder类属于org.elasticsearch.action.search包,在下文中一共展示了MultiSearchRequestBuilder类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: masterOperation

import org.elasticsearch.action.search.MultiSearchRequestBuilder; //导入依赖的package包/类
@Override
protected void masterOperation(ListStoresActionRequest request, ClusterState state,
                               ActionListener<ListStoresActionResponse> listener) throws Exception {
    String[] names = indexNameExpressionResolver.concreteIndexNames(state,
            new ClusterStateRequest().indices(IndexFeatureStore.DEFAULT_STORE, IndexFeatureStore.STORE_PREFIX + "*"));
    final MultiSearchRequestBuilder req = client.prepareMultiSearch();
    final List<Tuple<String, Integer>> versions = new ArrayList<>();
    Stream.of(names)
            .filter(IndexFeatureStore::isIndexStore)
            .map((s) -> clusterService.state().metaData().getIndices().get(s))
            .filter(Objects::nonNull)
            .filter((im) -> STORE_VERSION_PROP.exists(im.getSettings()))
            .forEach((m) -> {
                req.add(countSearchRequest(m));
                versions.add(tuple(m.getIndex().getName(),STORE_VERSION_PROP.get(m.getSettings())));
            });
    if (versions.isEmpty()) {
        listener.onResponse(new ListStoresActionResponse(Collections.emptyList()));
    } else {
        req.execute(wrap((r) -> listener.onResponse(toResponse(r, versions)), listener::onFailure));
    }
}
 
开发者ID:o19s,项目名称:elasticsearch-learning-to-rank,代码行数:23,代码来源:TransportListStoresAction.java


示例2: executeRequest

import org.elasticsearch.action.search.MultiSearchRequestBuilder; //导入依赖的package包/类
/**
 * Execute query request with filter and aggregations.
 * 
 * @param queries
 *            list of queries to execute
 * @return ES search response
 * @throws ODataApplicationException
 *             if any error appeared during executing request
 */
public MultiSearchResponse executeRequest(List<SearchQuery> queries)
        throws ODataApplicationException {
    MultiSearchRequestBuilder multiSearchRequestBuilder = client.prepareMultiSearch();
    for (SearchQuery query : queries) {
        Pagination pagination = query.getPagination();
        SearchRequestBuilder requestBuilder = client.prepareSearch(query.getIndex())
                .setTypes(query.getTypes()).setQuery(query.getQueryBuilder());
        if (pagination != null) {
            List<Sort> orderBy = pagination.getOrderBy();
            for (Sort sort : orderBy) {
                FieldSortBuilder sortQuery = SortBuilders.fieldSort(sort.getProperty())
                        .order(SortOrder.valueOf(sort.getDirection().toString()));
                requestBuilder.addSort(sortQuery);
            }
            requestBuilder.setSize(pagination.getTop()).setFrom(pagination.getSkip());
        }
        Set<String> fields = query.getFields();
        if (fields != null && !fields.isEmpty()) {
            requestBuilder.setFetchSource(fields.toArray(new String[fields.size()]), null);
        }
        multiSearchRequestBuilder.add(requestBuilder);
    }
    return executeRequest(multiSearchRequestBuilder);
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:34,代码来源:ESClient.java


示例3: testMultiSearchRequestBuilder

import org.elasticsearch.action.search.MultiSearchRequestBuilder; //导入依赖的package包/类
@Test
public void testMultiSearchRequestBuilder() throws IOException {
    SuggestionsRestService tested = new SuggestionsRestService();
    tested.searchClientService = Mockito.mock(SearchClientService.class);
    tested.log = Logger.getLogger("testlogger");

    MultiSearchRequestBuilder msrb = new MultiSearchRequestBuilder(null);
    SearchRequestBuilder srbNGram = new SearchRequestBuilder(null);
    SearchRequestBuilder srbFuzzy = new SearchRequestBuilder(null);

    msrb = tested.getProjectMultiSearchRequestBuilder(msrb,
            tested.getProjectSearchNGramRequestBuilder(srbNGram, "JBoss", 5),
            tested.getProjectSearchFuzzyRequestBuilder(srbFuzzy, "JBoss", 5));

    MultiSearchRequest msr = msrb.request();

    Assert.assertEquals(2, msr.requests().size());
}
 
开发者ID:macanhhuy,项目名称:dcp-api,代码行数:19,代码来源:SuggestionsRestServiceTest.java


示例4: msearch

import org.elasticsearch.action.search.MultiSearchRequestBuilder; //导入依赖的package包/类
private static MultiSearchRequestBuilder msearch(IndicesOptions options, String... indices) {
    MultiSearchRequestBuilder multiSearchRequestBuilder = client().prepareMultiSearch();
    if (options != null) {
        multiSearchRequestBuilder.setIndicesOptions(options);
    }
    return multiSearchRequestBuilder.add(client().prepareSearch(indices).setQuery(matchAllQuery()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:IndicesOptionsIntegrationIT.java


示例5: executeSearch

import org.elasticsearch.action.search.MultiSearchRequestBuilder; //导入依赖的package包/类
public MultiSearchResponse executeSearch(Client elasticClient,RelatedItemSearch[] searches) {
    MultiSearchRequestBuilder multiSearch = elasticClient.prepareMultiSearch();
    for(RelatedItemSearch search : searches) {

        if(search.getRelatedItemSearchType() == RelatedItemSearchType.FREQUENTLY_RELATED_WITH) {
            multiSearch.add(createFrequentlyRelatedContentSearch(search,elasticClient));
        }
    }
    log.debug("executing search {} request(s)",searches.length);
    return multiSearch.execute().actionGet(searchTimeout, TimeUnit.MILLISECONDS);
}
 
开发者ID:tootedom,项目名称:related,代码行数:12,代码来源:ElasticSearchFrequentlyRelatedItemSearchProcessor.java


示例6: prepareMultiSearch

import org.elasticsearch.action.search.MultiSearchRequestBuilder; //导入依赖的package包/类
@Override
public MultiSearchRequestBuilder prepareMultiSearch() {
    return new MultiSearchRequestBuilder(this, MultiSearchAction.INSTANCE);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java


示例7: prepareMultiSearch

import org.elasticsearch.action.search.MultiSearchRequestBuilder; //导入依赖的package包/类
@Override
public MultiSearchRequestBuilder prepareMultiSearch() {
	// TODO Auto-generated method stub
	return null;
}
 
开发者ID:winterstein,项目名称:elasticsearch-java-client,代码行数:6,代码来源:DummyClient.java


示例8: execute

import org.elasticsearch.action.search.MultiSearchRequestBuilder; //导入依赖的package包/类
@Override
public void execute(Tuple input) {
    _collector.ack(input);

    // this bolt can be connected to anything
    // we just want to trigger a new search when the input is a tick tuple
    if (!TupleUtils.isTick(input)) {
        return;
    }

    Status[] slist = new Status[] { Status.DISCOVERED, Status.ERROR,
            Status.FETCH_ERROR, Status.FETCHED, Status.REDIRECTION };

    MultiSearchRequestBuilder multi = connection.getClient()
            .prepareMultiSearch();

    // should be faster than running the aggregations
    // sent as a single multisearch
    for (Status s : slist) {
        SearchRequestBuilder request = connection.getClient()
                .prepareSearch(indexName).setTypes(docType).setFrom(0)
                .setSize(0).setExplain(false);
        request.setQuery(QueryBuilders.termQuery("status", s.name()));
        multi.add(request);
    }

    long start = System.currentTimeMillis();

    MultiSearchResponse response = multi.get();

    long end = System.currentTimeMillis();

    LOG.info("Multiquery returned in {} msec", end - start);

    for (int i = 0; i < response.getResponses().length; i++) {
        SearchResponse res = response.getResponses()[i].getResponse();
        long total = res.getHits().getTotalHits();
        latestStatusCounts.put(slist[i].name(), total);
    }

}
 
开发者ID:DigitalPebble,项目名称:storm-crawler,代码行数:42,代码来源:StatusMetricsBolt.java


示例9: allReader

import org.elasticsearch.action.search.MultiSearchRequestBuilder; //导入依赖的package包/类
public void allReader(ElastisearchCrawlerMultipleHits crawler) throws Exception {
	try {
		MultiSearchResponse.Item[] items = Elasticsearch.withRetry(new ElasticsearchWithRetry<Item[]>() {
			public Item[] call(Client client) throws NoNodeAvailableException {
				MultiSearchRequestBuilder multisearchrequestbuilder = new MultiSearchRequestBuilder(client);
				for (int pos = 0; pos < queries.size(); pos++) {
					multisearchrequestbuilder.add(queries.get(pos).getRequest());
				}
				return multisearchrequestbuilder.execute().actionGet().getResponses();
			}
		});
		
		SearchHit[] hits;
		SearchResponse response;
		for (int pos_response = 0; pos_response < items.length; pos_response++) {
			if (items[pos_response].isFailure()) {
				Loggers.ElasticSearch.warn("Search failed", new Exception(items[pos_response].getFailureMessage()));
				continue;
			}
			response = items[pos_response].getResponse();
			if (response == null) {
				continue;
			}
			if (response.getHits() == null) {
				continue;
			}
			hits = response.getHits().hits();
			if (hits.length == 0) {
				continue;
			}
			if (crawler.onMultipleResponse(response, Arrays.asList(hits)) == false) {
				return;
			}
		}
	} catch (IndexMissingException ime) {
		/**
		 * No items == no callbacks
		 */
		Loggers.ElasticSearch.debug("Index missing", ime);
		return;
	} catch (SearchPhaseExecutionException e) {
		Loggers.ElasticSearch.debug("No datas", e);
	}
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:45,代码来源:ElastisearchMultipleCrawlerReader.java


示例10: prepareMultiSearch

import org.elasticsearch.action.search.MultiSearchRequestBuilder; //导入依赖的package包/类
/**
 * Performs multiple search requests.
 */
MultiSearchRequestBuilder prepareMultiSearch();
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:Client.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PreemptionMessage类代码示例发布时间:2022-05-22
下一篇:
Java OnRequestPermissionsResultCallback类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap