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


Java SearchRequest類代碼示例

本文整理匯總了Java中com.amazonaws.services.cloudsearchdomain.model.SearchRequest的典型用法代碼示例。如果您正苦於以下問題:Java SearchRequest類的具體用法?Java SearchRequest怎麽用?Java SearchRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SearchRequest類屬於com.amazonaws.services.cloudsearchdomain.model包,在下文中一共展示了SearchRequest類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: search

import com.amazonaws.services.cloudsearchdomain.model.SearchRequest; //導入依賴的package包/類
public List<ObjectNode> search(String latlonnw, String latlonse) {
    String[] latlonnwa = latlonnw.split(",");
    String[] latlonsea = latlonse.split(",");

    Double latnw = Double.parseDouble(latlonnwa[0]);
    Double lonnw = Double.parseDouble(latlonnwa[1]);

    Double latse = Double.parseDouble(latlonsea[0]);
    Double lonse = Double.parseDouble(latlonsea[1]);

    String latlon = (latnw - ((latnw - latse) / 2)) + "," + (lonnw - ((lonnw - lonse) / 2));

    SearchRequest request = new SearchRequest().withSize(30L)
            .withQuery("latlon:['" + latlonnw + "','" + latlonse + "']")
            .withExpr("{\"distance\":\"haversin(" + latlon + ",latlon.latitude,latlon.longitude)\"}")
            .withSort("distance asc");

    request.setQueryParser(QueryParser.Structured);

    SearchResult result = domain.search(request);
    
    return result.getHits().getHit().stream().map(hit -> {
        return hit.getFields().entrySet().stream().collect(new EntrySetStringStringSetToObjectNodeCollector());
    }).collect(Collectors.toList());
}
 
開發者ID:coding4people,項目名稱:mosquito-report-api,代碼行數:26,代碼來源:Indexer.java

示例2: testSearchCenter

import com.amazonaws.services.cloudsearchdomain.model.SearchRequest; //導入依賴的package包/類
@Test
public void testSearchCenter() {
    when(amazonCloudSearch.describeDomains(any())).thenReturn(new DescribeDomainsResult()
            .withDomainStatusList(Lists.newArrayList(new DomainStatus().withSearchService(new ServiceEndpoint().withEndpoint("http://localhost")))));

    HashMap<String, List<String>> map = Maps.newHashMap();
    map.put("property", Lists.newArrayList("value"));
    SearchResult expected = new SearchResult().withHits(new Hits().withHit(new Hit().withFields(map)));
    
    ArgumentCaptor<SearchRequest> requestCaptor = ArgumentCaptor.forClass(SearchRequest.class);
    
    when(domain.search(requestCaptor.capture())).thenReturn(expected);
    
    List<ObjectNode> result = getService(ModelIndexer.class).searchCenter("0,0");
    
    SearchRequest request = requestCaptor.getValue();
    
    assertEquals("value", result.get(0).get("property").asText());
    assertEquals("latlon:['0.1,-0.1','-0.1,0.1']", request.getQuery());
    assertEquals("{\"distance\":\"haversin(0.0,0.0,latlon.latitude,latlon.longitude)\"}", request.getExpr());
    assertEquals("distance asc", request.getSort());
    assertEquals(Long.valueOf(30L), request.getSize());
}
 
開發者ID:coding4people,項目名稱:mosquito-report-api,代碼行數:24,代碼來源:IndexerTest.java

示例3: search

import com.amazonaws.services.cloudsearchdomain.model.SearchRequest; //導入依賴的package包/類
public List<SearchResult> search(String domainName, SearchRequest searchRequest) {
	AmazonCloudSearchDomainAsyncClient domainClient = cloudSearchDomainAsyncClients.get(domainName);
	if (domainClient == null) {
		throw new IllegalArgumentException(domainName + " not known");
	}
	if (progressListener != null) {
		searchRequest.setGeneralProgressListener(progressListener);
	}
	List<SearchResult> searchResults = new ArrayList<>();
	int found = 0;
	while (true) {
		SearchResult searchResult = domainClient.search(searchRequest);
		searchResults.add(searchResult);
		Hits hits = searchResult.getHits();
		log.debug("found {} {}", found, hits.getFound());
		int size = hits.getHit().size();
		found += size;
		if (size == 0 || hits.getFound() == found || hits.getCursor() == null) {
			break;
		}
		searchRequest.setCursor(hits.getCursor());
	}
	return searchResults;
}
 
開發者ID:efenderbosch,項目名稱:spring-boot-aws-cloudsearch,代碼行數:25,代碼來源:CloudSearchClient.java

示例4: buildRequest

import com.amazonaws.services.cloudsearchdomain.model.SearchRequest; //導入依賴的package包/類
private static SearchRequest buildRequest(SearchQuery searchQuery, Localization localization) {
    SearchRequest request = new SearchRequest();
    request.setQuery(searchQuery.getQueryDetails().getQueryText());
    request.setStart((long) (searchQuery.getStart() - 1));
    request.setSize((long) searchQuery.getPageSize());
    request.setFilterQuery("publicationid:'" + localization.getId() + "'");
    request.putCustomQueryParameter("q.options", QUERY_OPTIONS);
    request.putCustomQueryParameter("highlight.body", HIGHLIGHT_SETTINGS);
    request.putCustomQueryParameter("highlight.summary", HIGHLIGHT_SETTINGS);
    request.putCustomQueryParameter("highlight.title", HIGHLIGHT_SETTINGS);
    return request;
}
 
開發者ID:sdl,項目名稱:dxa-modules,代碼行數:13,代碼來源:AwsCloudSearchProvider.java

示例5: executeQuery

import com.amazonaws.services.cloudsearchdomain.model.SearchRequest; //導入依賴的package包/類
@Override
public void executeQuery(SearchQuery searchQuery, Localization localization) {
    SearchRequest request = buildRequest(searchQuery, localization);
    processResults(searchQuery, getClient(localization).search(request));
}
 
開發者ID:sdl,項目名稱:dxa-modules,代碼行數:6,代碼來源:AwsCloudSearchProvider.java


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