/** * Requests SearchResult for a query. * * @param query the query to execute. * @param index the index from which to return results. * @param numresults the number of results to return. * @param rpcServerUrl the active gateway. * * @throws IOException if remote server returns error. */ public SearchResult search(String query, Integer index, Integer numResults, String rpcServerUrl) throws IOException { OperationQueue opQueue = new OperationQueue(); opQueue.search(query, index, numResults); Map<ParamsProperty, Object> response = makeSingleOperationRpc(opQueue, rpcServerUrl); return (SearchResult) response.get(ParamsProperty.SEARCH_RESULTS); }
/** * Performs search using Data API. */ protected SearchResult performSearch(SearchRequest searchRequest, ParticipantId user) { OperationQueue opQueue = new OperationQueue(); opQueue.search(searchRequest.getQuery(), searchRequest.getIndex(), searchRequest.getNumResults()); OperationContextImpl context = new OperationContextImpl(waveletProvider, converterManager.getEventDataConverter(ProtocolVersion.DEFAULT), conversationUtil); LOG.fine( "Performing query: " + searchRequest.getQuery() + " [" + searchRequest.getIndex() + ", " + (searchRequest.getIndex() + searchRequest.getNumResults()) + "]"); OperationRequest operationRequest = opQueue.getPendingOperations().get(0); String opId = operationRequest.getId(); OperationUtil.executeOperation(operationRequest, operationRegistry, context, user); JsonRpcResponse jsonRpcResponse = context.getResponses().get(opId); SearchResult searchResult = (SearchResult) jsonRpcResponse.getData().get(ParamsProperty.SEARCH_RESULTS); return searchResult; } }