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

Java SearchType类代码示例

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

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



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

示例1: startScroll

import io.searchbox.params.SearchType; //导入依赖的package包/类
String startScroll(String type) {

		Builder builder = new Search.Builder(versionHelper.createQuery(query));
		builder.addIndex(indexName);
		builder.addType(type);
		builder.setParameter(Parameters.SIZE, BATCH_SIZE);
		builder.setParameter(Parameters.EXPLAIN, false);
		// searchRequestBuilder.setNoFields();
		builder.setParameter(Parameters.VERSION, true);
		builder.setSearchType(SearchType.SCAN);
		builder.setParameter(Parameters.SCROLL, SCROLL_TIME_IN_MINUTES + "m");

		try {
			JestResult result = client.execute(builder.build());
			if (result.isSucceeded()) {
				return result.getJsonObject().get("_scroll_id").getAsString();
			} else {
				throw new RuntimeException("failed to start scroll operation: " + result.getJsonObject());
			}
		} catch (Exception e) {
			throw new RuntimeException("failed to start scroll operation", e);
		}

	}
 
开发者ID:molindo,项目名称:molindo-elasticsync,代码行数:25,代码来源:ElasticsearchJestIndex.java


示例2: executeSearch

import io.searchbox.params.SearchType; //导入依赖的package包/类
private SearchResult executeSearch(Query query, SearchSourceBuilder request) {

		Search.Builder search = new Search.Builder(request.toString());
		if (query != null) {
			search.
					addType(query.getTypes()).
					addIndex(query.getIndices()).
					setSearchType(SearchType.valueOf(query.getSearchType().name()));
		}

		return new ExtendedSearchResult(execute(search.build()));
	}
 
开发者ID:VanRoy,项目名称:spring-data-jest,代码行数:13,代码来源:JestElasticsearchTemplate.java


示例3: initScroll

import io.searchbox.params.SearchType; //导入依赖的package包/类
private void initScroll() throws StorageException {
    try {
        Search search = new Search.Builder(query).addIndex(getIndexName()).addType(entityType)
                .setSearchType(SearchType.SCAN).setParameter(Parameters.SCROLL, "1m").build();
        SearchResult response = esClient.execute(search);
        scrollId = response.getJsonObject().get("_scroll_id").getAsString();
    } catch (IOException e) {
        throw new StorageException(e);
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:11,代码来源:EsStorage.java


示例4: searchDocumentRevisions

import io.searchbox.params.SearchType; //导入依赖的package包/类
@Override
@RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID})
public List<DocumentRevision> searchDocumentRevisions(DocumentSearchQuery documentSearchQuery, int from, int size) throws AccountNotFoundException, NotAllowedException {

    String workspaceId = documentSearchQuery.getWorkspaceId();
    QueryBuilder query = IndexerQueryBuilder.getSearchQueryBuilder(documentSearchQuery);
    LOGGER.log(Level.FINE, query.toString());
    SearchResult searchResult;

    try {
        searchResult = esClient.execute(new Search.Builder(
                        new SearchSourceBuilder()
                                .query(query)
                                .from(from)
                                .size(size)
                                .toString())
                        .addIndex(IndexerUtils.formatIndexName(workspaceId))
                        .addType(IndexerMapping.DOCUMENT_TYPE)
                        .setSearchType(SearchType.QUERY_THEN_FETCH)
                        .build()
        );

    } catch (IOException e) {
        Account account = accountManager.getMyAccount();
        throw new NotAllowedException(new Locale(account.getLanguage()), "IndexerNotAvailableForSearch");
    }

    if (searchResult.isSucceeded()) {

        List<SearchResult.Hit<Map, Void>> hits = searchResult.getHits(Map.class);
        Set<DocumentIterationKey> documentIterationKeys = new HashSet<>();

        if (hits != null) {
            for (SearchResult.Hit<Map, Void> hit : hits) {
                Map<?, ?> source = hit.source;
                documentIterationKeys.add(IndexerMapping.getDocumentIterationKey(source));
            }
        }

        LOGGER.log(Level.INFO, "Results: " + documentIterationKeys.size());
        return documentIterationKeysToDocumentRevisions(documentSearchQuery.isFetchHeadOnly(), documentIterationKeys);

    } else {
        throw new NotAllowedException(searchResult.getErrorMessage());
    }
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:47,代码来源:IndexerManagerBean.java


示例5: searchPartRevisions

import io.searchbox.params.SearchType; //导入依赖的package包/类
@Override
@RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID})
public List<PartRevision> searchPartRevisions(PartSearchQuery partSearchQuery, int from, int size) throws AccountNotFoundException, NotAllowedException {

    String workspaceId = partSearchQuery.getWorkspaceId();
    QueryBuilder query = IndexerQueryBuilder.getSearchQueryBuilder(partSearchQuery);
    LOGGER.log(Level.FINE, query.toString());
    SearchResult searchResult;

    try {
        searchResult = esClient.execute(new Search.Builder(
                        new SearchSourceBuilder()
                                .query(query)
                                .from(from)
                                .size(size)
                                .toString())
                        .addIndex(IndexerUtils.formatIndexName(workspaceId))
                        .addType(IndexerMapping.PART_TYPE)
                        .setSearchType(SearchType.QUERY_THEN_FETCH)
                        .build()
        );

    } catch (IOException e) {
        Account account = accountManager.getMyAccount();
        throw new NotAllowedException(new Locale(account.getLanguage()), "IndexerNotAvailableForSearch");
    }

    if (searchResult.isSucceeded()) {
        List<SearchResult.Hit<Map, Void>> hits = searchResult.getHits(Map.class);
        Set<PartIterationKey> partIterationKeys = new HashSet<>();

        if (hits != null) {
            for (SearchResult.Hit<Map, Void> hit : hits) {
                Map<?, ?> source = hit.source;
                partIterationKeys.add(IndexerMapping.getPartIterationKey(source));
            }
        }

        LOGGER.log(Level.INFO, "Results: " + partIterationKeys.size());
        return partIterationKeysToPartRevisions(partSearchQuery.isFetchHeadOnly(), partIterationKeys);
    } else {
        throw new NotAllowedException(searchResult.getErrorMessage());
    }
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:45,代码来源:IndexerManagerBean.java


示例6: setSearchType

import io.searchbox.params.SearchType; //导入依赖的package包/类
public ExileToolsSearchAction.Builder setSearchType(SearchType searchType) {
    return setParameter(Parameters.SEARCH_TYPE, searchType);
}
 
开发者ID:thirdy,项目名称:blackmarket,代码行数:4,代码来源:ExileToolsSearchAction.java


示例7: executeQuery

import io.searchbox.params.SearchType; //导入依赖的package包/类
public void executeQuery(String query, int pageSize,String index, String docType,int docLimit){
	
	Search search = new Search.Builder(query)
								 .addIndex(index)
								 .addType(docType)
								 .setParameter(Parameters.SEARCH_TYPE,SearchType.SCAN)
								 .setParameter(Parameters.SIZE, pageSize)
								 .setParameter(Parameters.SCROLL, SCROLL)
								 .build();
	System.out.println(query + "$$$$");
	
	boolean runTikaExtractor = true;
	
	if(this.runTika == 0){
		runTikaExtractor = false;
	}
	else if(this.runTika == 1) {
		runTikaExtractor= true;
	}
	
	try {

           JestResult searchResult = client.execute(search);
           //System.out.println(searchResult.getJsonString());
           String scrollId = searchResult.getJsonObject().get("_scroll_id").getAsString();

           int currentResultSize = 0;
           int numDocs = 0;
           
           do {
           	JSONArray jArrayResult = new JSONArray();
           	
               SearchScroll scrollRequest = new SearchScroll.Builder(scrollId, SCROLL)
                                                   .setParameter(Parameters.SIZE, pageSize)
                                                   .build();

               JestResult scrollResult = client.execute(scrollRequest);
               scrollId = scrollResult.getJsonObject().get("_scroll_id").getAsString();
               
               JSONObject jObj =  (JSONObject) JSONSerializer.toJSON(scrollResult.getJsonString());
               
               JSONArray jArrayHits = jObj.getJSONObject("hits").getJSONArray("hits");
               
               for(int i=0;i<jArrayHits.size();i++){
               	
               	if(runTikaExtractor){
               		jArrayResult.add(extractTika(jArrayHits.getString(i)).toString());
               	}else{
               		jArrayResult.add(jArrayHits.getString(i).toString());
               	}
               }
               writeToFile(jArrayResult);
               // Note: Current result size will be Page Size * number of shards
               currentResultSize = jArrayHits.size();
               numDocs+=currentResultSize;
               System.out.println("num docs:" + String.valueOf(numDocs));
               if(docLimit != -1 && numDocs >= docLimit){
               	break;
               }
           } while (currentResultSize != 0);
           
          
       } catch (IOException e) {
           LOG.error("Error retrieving from Elasticsearch", e);
       }
}
 
开发者ID:usc-isi-i2,项目名称:dig-elasticsearch,代码行数:67,代码来源:ScanAndScroll.java


示例8: setSearchType

import io.searchbox.params.SearchType; //导入依赖的package包/类
public JestSearchRequestBuilder setSearchType(SearchType searchType) {
    this.searchType = searchType;
    return this;
}
 
开发者ID:CedricGatay,项目名称:play2-elasticsearch-jest,代码行数:5,代码来源:JestSearchRequestBuilder.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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