本文整理匯總了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());
}
示例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());
}
示例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;
}
示例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;
}
示例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));
}