Search the catalog and return the results

    :returns: Catalog search results
    :rtype: iterable
517926
def get_search_results(portal_type=None, uid=None, **kw):
    

    # If we have an UID, return the object immediately
    if uid is not None:
        logger.info("UID '%s' found, returning the object immediately" % uid)
        return u.to_list(get_object_by_uid(uid))

    # allow to search search for the Plone Site with portal_type
    include_portal = False
    if u.to_string(portal_type) == "Plone Site":
        include_portal = True

    # The request may contain a list of portal_types, e.g.
    # `?portal_type=Document&portal_type=Plone Site`
    if "Plone Site" in u.to_list(req.get("portal_type")):
        include_portal = True

    # Build and execute a catalog query
    results = search(portal_type=portal_type, uid=uid, **kw)

    if include_portal:
        results = list(results) + u.to_list(get_portal())

    return results
40147
def get_catalogs_by_ids(self, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.BinLookupSession.get_bins_by_ids
        catalogs = self._get_provider_session('catalog_lookup_session').get_catalogs_by_ids(*args, **kwargs)
        cat_list = []
        for cat in catalogs:
            cat_list.append(Catalog(self._provider_manager, cat, self._runtime, self._proxy))
        return CatalogList(cat_list)
1328044
def search(self):
        
        self.set_url()
        listings = []
        request = Request(debug=self._debug)
        url = self.get_url()
        soup = request.get(url)
        divs = soup.find_all("div", {"class": "box"})
        [listings.append(Listing(div, debug=self._debug)) for div in divs]
        return listings
1242837
def search(query)
      get('/v1/search'.freeze, { q: query })
    rescue => e
      logger.warn "API v1 - Search failed #{e.backtrace}"
      { 'results' => catalog(query) }
    end
1366207
def query_parent_objects(self, context, query=None):
        

        # return the object values if we have no catalog query
        if query is None:
            return self.get_parent_objects(context)

        # avoid undefined reference of catalog in except...
        catalog = None

        # try to fetch the results via the catalog
        try:
            catalogs = api.get_catalogs_for(context)
            catalog = catalogs[0]
            return map(api.get_object, catalog(query))
        except (IndexError, UnicodeDecodeError, ParseError, APIError) as e:
            # fall back to the object values of the parent
            logger.warn("UniqueFieldValidator: Catalog query {} failed "
                        "for catalog {} ({}) -> returning object values of {}"
                        .format(query, repr(catalog), str(e),
                                repr(api.get_parent(context))))
            return self.get_parent_objects(context)
817134
def collections(self):
        
        iterator = self._firestore_api.list_collection_ids(
            self._database_string, metadata=self._rpc_metadata
        )
        iterator.client = self
        iterator.item_to_value = _item_to_collection_ref
        return iterator
315393
def __search(self):
        

        self.__search_results = []

        editorsFiles = self.__container.default_target in self.__location.targets and \
                       [editor.file for editor in self.__container.script_editor.list_editors()] or []
        self.__search_editors_files(editorsFiles)

        self.__search_files(self.__location.files)

        for directory in self.__location.directories:
            if self.__interrupt:
                return

            files_walker = foundations.walkers.files_walker(directory,
                                                            self.__location.filters_in,
                                                            list(itertools.chain(self.__location.filters_out,
                                                                                 self.__location.files,
                                                                                 editorsFiles)))
            self.__search_files(files_walker)

        not self.__interrupt and self.searchFinished.emit(self.__search_results)
1184485
def _search(self):
        
        results = []
        for _id in self.doc_dict:
            entry = self.doc_dict[_id]
            if entry.doc is not None:
                results.append(entry.merged_dict)
        return results
935826
def find(cls, *args, **kwargs):
        
        return list(cls.collection.find(*args, **kwargs))
625775
def results(self):
        
        if not self.in_search_mode():
            return self.get_queryset()

        # we are doing a search
        objects = self.search()

        # if objects isn't a Search object, just return it, since it's
        # (hopefully) just a list or queryset.
        if not isinstance(objects, Search):
            return objects

        if not self.is_valid_query(objects):
            self.add_error(None, forms.ValidationError("Invalid Query", code="invalid-query"))
            return []

        # convert the search results to something that can be iterated over, and paged
        return Pageable(objects, self.get_queryset())
161197
def get_queryset(self):
        
        self.queryset = super(EntryCategoryListView, self).get_queryset()
        return self.get_ordered_entries(self.queryset)
274942
def get_books(self):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.BinLookupSession.get_bins_template
        catalogs = self._get_provider_session('book_lookup_session').get_books()
        cat_list = []
        for cat in catalogs:
            cat_list.append(Book(self._provider_manager, cat, self._runtime, self._proxy))
        return BookList(cat_list)
881290
def get_search_index_for(catalog):
    
    searchable_text_index = "SearchableText"
    listing_searchable_text_index = "listing_searchable_text"

    if catalog == CATALOG_ANALYSIS_REQUEST_LISTING:
        tool = api.get_tool(catalog)
        indexes = tool.indexes()
        if listing_searchable_text_index in indexes:
            return listing_searchable_text_index

    return searchable_text_index
581009
def fetch(self):
        
        returnResults = []

        results = self._query.run()
        for result in results:
            if self._join:
                # Because we can tell the models to ignore certian fields,
                # through the protectedItems blacklist, we can nest models by
                # name and have each one act normal and not accidentally store
                # extra data from other models
                item = self._model.fromRawEntry(**result["left"])
                joined = self._join.fromRawEntry(**result["right"])
                item.protectedItems = self._joinedField
                item[self._joinedField] = joined

            else:
                item = self._model.fromRawEntry(**result)

            returnResults.append(item)

        self._documents = returnResults
        return self._documents
84539
def all(self):
        
        logger.debug(f'Query `{self.__class__.__name__}` objects with filters {self}')

        # Destroy any cached results
        self._result_cache = None

        # Fetch Model class and connected repository from Repository Factory
        model_cls = repo_factory.get_model(self._entity_cls)
        repository = repo_factory.get_repository(self._entity_cls)

        # order_by clause must be list of keys
        order_by = self._entity_cls.meta_.order_by if not self._order_by else self._order_by

        # Call the read method of the repository
        results = repository.filter(self._criteria, self._offset, self._limit, order_by)

        # Convert the returned results to entity and return it
        entity_items = []
        for item in results.items:
            entity = model_cls.to_entity(item)
            entity.state_.mark_retrieved()
            entity_items.append(entity)
        results.items = entity_items

        # Cache results
        self._result_cache = results

        return results
1007751
def get_list(
        self,
        search='',
        start=0,
        limit=0,
        order_by='',
        order_by_dir='ASC',
        published_only=False,
        minimal=False
    ):
        

        parameters = {}
        args = ['search', 'start', 'limit', 'minimal']
        for arg in args:
            if arg in locals() and locals()[arg]:
                parameters[arg] = locals()[arg]
        if order_by:
            parameters['orderBy'] = order_by
        if order_by_dir:
            parameters['orderByDir'] = order_by_dir
        if published_only:
            parameters['publishedOnly'] = 'true'
        response = self._client.session.get(
            self.endpoint_url, params=parameters
        )
        return self.process_response(response)
273929
def query(self):
        
        tree = pypeg2.parse(self._query, parser(), whitespace="")
        for walker in query_walkers():
            tree = tree.accept(walker)
        return tree