Performs a search of the explicitly configured {@link IPortalSearchService}s. This is done as
an event handler so that it can run concurrently with the other portlets handling the search
request
434931
@SuppressWarnings("unchecked")
    @EventMapping(SearchConstants.SEARCH_REQUEST_QNAME_STRING)
    public void handleSearchRequest(EventRequest request, EventResponse response) {
        // UP-3887 Design flaw.  Both the searchLauncher portlet instance and the search portlet
        // instance receive
        // searchRequest and searchResult events because they are in the same portlet code base (to
        // share
        // autosuggest_handler.jsp and because we have to calculate the search portlet url for the
        // ajax call)
        // and share the portlet.xml which defines the event handling behavior.
        // If this instance is the searchLauncher, ignore the searchResult. The search was submitted
        // to the search
        // portlet instance.
        final String searchLaunchFname =
                request.getPreferences().getValue(SEARCH_LAUNCH_FNAME, null);
        if (searchLaunchFname != null) {
            // Noisy in debug mode so commented out log statement
            // logger.debug("SearchLauncher does not participate in SearchRequest events so
            // discarding message");
            return;
        }

        final Event event = request.getEvent();
        final SearchRequest searchQuery = (SearchRequest) event.getValue();

        // Map used to track searches that have been handled, used so that one search doesn't get
        // duplicate results
        ConcurrentMap<String, Boolean> searchHandledCache;
        final PortletSession session = request.getPortletSession();
        synchronized (org.springframework.web.portlet.util.PortletUtils.getSessionMutex(session)) {
            searchHandledCache =
                    (ConcurrentMap<String, Boolean>)
                            session.getAttribute(
                                    SEARCH_HANDLED_CACHE_NAME, PortletSession.APPLICATION_SCOPE);
            if (searchHandledCache == null) {
                searchHandledCache =
                        CacheBuilder.newBuilder()
                                .maximumSize(20)
                                .expireAfterAccess(5, TimeUnit.MINUTES)
                                .<String, Boolean>build()
                                .asMap();
                session.setAttribute(
                        SEARCH_HANDLED_CACHE_NAME,
                        searchHandledCache,
                        PortletSession.APPLICATION_SCOPE);
            }
        }

        final String queryId = searchQuery.getQueryId();
        if (searchHandledCache.putIfAbsent(queryId, Boolean.TRUE) != null) {
            // Already handled this search request
            return;
        }

        // Create the results
        final SearchResults results = new SearchResults();
        results.setQueryId(queryId);
        results.setWindowId(request.getWindowID());
        final List<SearchResult> searchResultList = results.getSearchResult();

        // Run the search for each service appending the results
        for (IPortalSearchService searchService : searchServices) {
            try {
                logger.debug(
                        "For queryId {}, query '{}', searching search service {}",
                        queryId,
                        searchQuery.getSearchTerms(),
                        searchService.getClass().toString());
                final SearchResults serviceResults =
                        searchService.getSearchResults(request, searchQuery);
                logger.debug(
                        "For queryId {}, obtained {} results from search service {}",
                        queryId,
                        serviceResults.getSearchResult().size(),
                        searchService.getClass().toString());
                searchResultList.addAll(serviceResults.getSearchResult());
            } catch (Exception e) {
                logger.warn(
                        searchService.getClass()
                                + " threw an exception when searching, it will be ignored. "
                                + searchQuery,
                        e);
            }
        }

        // Respond with a results event if results were found
        if (!searchResultList.isEmpty()) {
            response.setEvent(SearchConstants.SEARCH_RESULTS_QNAME, results);
        }
    }
227542
final Search loadExternalSearch(String classSimpleName) {
		ServiceLoader<Search> searchLoader = ServiceLoader.load(Search.class, Para.getParaClassLoader());
		for (Search search : searchLoader) {
			if (search != null && classSimpleName.equalsIgnoreCase(search.getClass().getSimpleName())) {
				return search;
			}
		}
		return null;
	}
462404
private void beginSearch() throws RemoteException {
        org.fcrepo.server.types.gen.FieldSearchQuery genFieldSearchQuery =
                TypeUtility.convertFieldSearchQueryToGenFieldSearchQuery(query);
        org.fcrepo.server.types.gen.FieldSearchResult searchResult =
                apia.findObjects(org.fcrepo.server.utilities.TypeUtility.convertStringtoAOS(OBJECT_RESULT_FIELDS),
                                 MAX_FIND_RESULTS,
                                 genFieldSearchQuery);
        FieldSearchResult fsr =
                TypeUtility
                        .convertGenFieldSearchResultToFieldSearchResult(searchResult);
        for (ObjectFields fields : fsr.objectFieldsList()) {
            stash.add(fields.getPid());
        }
        token = fsr.getToken();
    }
1335619
@Override
    public void search(final Query query) {
        getDispatcher().invokeLater(new AsyncTask(SEARCH, listeners) {
            @Override
            public void invoke(List<TwitterListener> listeners) throws TwitterException {
                QueryResult result = twitter.search(query);
                for (TwitterListener listener : listeners) {
                    try {
                        listener.searched(result);
                    } catch (Exception e) {
                        logger.warn("Exception at search", e);
                    }
                }
            }
        });
    }
296380
public <T> ESDatas<T> searchAllParallel(String index,  int fetchSize ,Class<T> type,int thread) throws ElasticSearchException{
		return searchAllParallel(index,  fetchSize,(ScrollHandler<T>)null,type,thread);
	}
128922
public void search(AjaxRequestTarget ajaxRequestTarget, String value)
	{
		ajaxRequestTarget.appendJavaScript(this.search(value).render().toString());
	}
974682
@Override
    protected void searchStep() {
        // execute pipeline
        pipeline.stream().forEachOrdered(l -> {
            // attach listener
            l.addSearchListener(pipelineListener);
            // set initial solution (copy!)
            l.setCurrentSolution(Solution.checkedCopy(getCurrentSolution()));
            // run local search
            l.start();
            // get best solution found by search l
            SolutionType bestSol = l.getBestSolution();
            Evaluation bestSolEvaluation = l.getBestSolutionEvaluation();
            Validation bestSolValidation = l.getBestSolutionValidation();
            // if not null and different from current solution (i.e. improved):
            // update current and best solution accordingly
            if(bestSol != null && !bestSol.equals(getCurrentSolution())){
                updateCurrentAndBestSolution(bestSol, bestSolEvaluation, bestSolValidation);
            }
            // remove listener
            l.removeSearchListener(pipelineListener);
        });
        // pipeline complete: stop search
        stop();
    }
915080
public <T> ESDatas<T> searchAllParallel(String index,  Class<T> type,int thread) throws ElasticSearchException{
			return searchAllParallel(index,  ClientInterface.DEFAULT_FETCHSIZE,type,thread);
	}
112848
def start_search(self):
        

        self._asyncio_loop = asyncio.get_event_loop()

        # Creating Broadcast Receiver
        coroutine_listen = self._asyncio_loop.create_datagram_endpoint(
            lambda: self.KNXSearchBroadcastReceiverProtocol(
                self._process_response,
                self._timeout_handling,
                self._timeout,
                self._asyncio_loop
            ), local_addr=(self._broadcast_ip_address, 0)
        )
        self._listener_transport, listener_protocol = \
            self._asyncio_loop.run_until_complete(coroutine_listen)

        # We are ready to fire the broadcast message
        coroutine_broadcaster = self._asyncio_loop.create_datagram_endpoint(
            lambda: self.KNXSearchBroadcastProtocol(
                self._asyncio_loop,
                self._listener_transport.get_extra_info('sockname')
                [1]),
            remote_addr=(self._broadcast_address, self._broadcast_port))

        self._broadcaster_transport, broadcast_protocol = \
            self._asyncio_loop.run_until_complete(coroutine_broadcaster)
        # Waiting for all Broadcast receive or timeout
        self._asyncio_loop.run_forever()

        # Got Response or Timeout
        if self._resolved_gateway_ip_address is None and \
           self._resolved_gateway_ip_port is None:
            LOGGER.debug("Gateway not found!")
            return None
        else:
            LOGGER.debug("Gateway found at %s:%s",
                         self._resolved_gateway_ip_address,
                         self._resolved_gateway_ip_port)

            return self._resolved_gateway_ip_address, \
                self._resolved_gateway_ip_port
503927
public final MaxSATResult search(final MaxSATHandler handler) {
    this.handler = handler;
    if (handler != null)
      handler.startedSolving();
    final MaxSATResult result = search();
    if (handler != null)
      handler.finishedSolving();
    this.handler = null;
    return result;
  }
326695
@Override
    public PagedSearchResult discoverSearch(UploadSearchParams uploadSearchParams) {
        try {
            return postImageSearch(uploadSearchParams, ENDPOINT_DISCOVER_SEARCH);
        } catch (InternalViSearchException e) {
            return new PagedSearchResult(e.getMessage(), e.getCause(), e.getServerRawResponse());
        }
    }
238733
@UiHandler("m_searchInput")
    protected void onSearchInputChange(ValueChangeEvent<String> event) {

        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(event.getValue()) && (event.getValue().length() >= 3)) {
            m_tabHandler.setSearchQuery(event.getValue());
        } else {
            m_tabHandler.setSearchQuery(null);
        }
    }
495444
function instantSearch() {

    const q = $("#searchbox").val();
    if (q === '')
        return;

    const matcher = "/matcher?beginsWith=" + q;
    const request = host + matcher;

    console.debug(request);

    $.getJSON(request, '', {})
        .done(data => {

            $("#searchbox").autocomplete({
                source: data,
                select: (event) => {
                    event.stopPropagation();
                    $("#search").trigger("click");
                }
            });
        })
        .fail((d, textStatus, error) => {

            const err = d.status + " " + error + " -> message: " + d.responseText;
            bootstrapAlert.error(err);
            console.error(`Search request failed: \n ${err}`);
        });
}
177910
public SearchRequestBuilder getSearchRequestBuilder(boolean isSetExplain,
            String[] indices, String[] types) {
        return getSearchRequestBuilder(isSetExplain, indices, types, null);
    }
771617
@Override
	public void search(String crs, final VectorServerLayer layer, SearchCriterion[] criteria,
			LogicalOperator operator, int maxResultSize, final FeatureMapFunction callback) {
		SearchFeatureRequest request = new SearchFeatureRequest();
		request.setBooleanOperator(operator.getValue());
		request.setCriteria(criteria);
		request.setMax(maxResultSize);
		request.setLayerId(layer.getServerLayerId());
		request.setCrs(crs);
		request.setFilter(layer.getFilter());
		request.setFeatureIncludes(11);

		GwtCommand command = new GwtCommand(SearchFeatureRequest.COMMAND);
		command.setCommandRequest(request);
		GeomajasServerExtension.getInstance().getCommandService().execute(command,
				new AbstractCommandCallback<SearchFeatureResponse>() {

					public void execute(SearchFeatureResponse response) {
						List<Feature> features = new ArrayList<Feature>();
						for (org.geomajas.layer.feature.Feature feature : response.getFeatures()) {
							features.add(create(feature, layer));
						}
						Map<FeaturesSupported, List<Feature>> mapping = new HashMap<FeaturesSupported, List<Feature>>();
						mapping.put(layer, features);
						callback.execute(mapping);
					}
				});
	}
940135
def runSearchDatasets(self, request):
        
        return self.runSearchRequest(
            request, protocol.SearchDatasetsRequest,
            protocol.SearchDatasetsResponse,
            self.datasetsGenerator)
1014180
public static HttpResult executeSearch(AsyncHttpClient client, HttpMethod method, String host,
                                     String path, String searchQuery) {
        RequestBuilder requestBuilder = new RequestBuilder(method.name());

        log.debug("Executing request against host {} with path {}",host,path);
        if(searchQuery!=null) {
            requestBuilder.setBody(searchQuery);
        }

        requestBuilder.setUrl(host + path);
        try {
            Response res = client.executeRequest(requestBuilder.build(),new AsyncCompletionHandlerBase()).get();
            return new HttpResult(HttpSearchExecutionStatus.OK,res.getResponseBody());
        } catch (Exception e) {
            Throwable cause = e.getCause();
            if(cause!=null) {
                if(cause instanceof ConnectException)
                {
                    log.error("Unable to connect to {}",host,e);
                    return HttpResult.CONNECTION_FAILURE;
                }
                else if (cause instanceof TimeoutException) {
                    log.error("Request timeout talking to {}",host,e);
                    return HttpResult.REQUEST_TIMEOUT_FAILURE;
                }
                else if (cause instanceof IOException && cause.getMessage().equalsIgnoreCase("closed")) {
                    log.warn("Unable to use client, client is closed");
                    return HttpResult.CLIENT_CLOSED;
                }
                else {
                    log.error("Exception talking to {}",host,e);
                    return new HttpResult(HttpSearchExecutionStatus.REQUEST_FAILURE,null);
                }
            }
            else {
                if (e instanceof IOException && e.getMessage().equalsIgnoreCase("closed")) {
                    log.warn("Unable to use client, client is closed");
                    return HttpResult.CLIENT_CLOSED;
                } else {
                    log.error("Exception talking to {}",host,e);
                    return new HttpResult(HttpSearchExecutionStatus.REQUEST_FAILURE,null);
                }
            }
        }
    }