Count all rows with condition
@param  string $searchAttr
@param  string $searchValue
@return integer
547155
public function countFiltered($searchAttr, $searchValue, $richFilters)
    {
        $collection = $this->getFiltered(null, null, null, null, $searchAttr, $searchValue, $richFilters);
        return count($collection);
    }
591398
protected function getExcludeFiltersComponent(SearchQuery $searchQuery)
    {
        $fq = array();
        foreach ($searchQuery->exclude as $field => $values) {
            // Handle namespaced class names
            $field = $this->sanitiseClassName($field);

            $excludeq = [];
            $missing = false;

            foreach ($values as $value) {
                if ($value === SearchQuery::$missing) {
                    $missing = true;
                } elseif ($value === SearchQuery::$present) {
                    $excludeq[] = "{$field}:[* TO *]";
                } elseif ($value instanceof SearchQuery_Range) {
                    $start = $value->start;
                    if ($start === null) {
                        $start = '*';
                    }
                    $end = $value->end;
                    if ($end === null) {
                        $end = '*';
                    }
                    $excludeq[] = "$field:[$start TO $end]";
                } else {
                    $excludeq[] = $field . ':"' . $value . '"';
                }
            }

            $fq[] = ($missing ? "+{$field}:[* TO *] " : '') . '-(' . implode(' ', $excludeq) . ')';
        }
        return $fq;
    }
1038495
public function get($table, $colname, $searchterm, $proc = "="){
    $rownumbs = $this->search_term($table, $colname, $searchterm);

        if($colname == "id"){
        $returnarr = array();

            foreach ($this->cols[$table] as $tbcols){
            $searchio_e         = $this->readdb($table, $tbcols);
            $returnarr[$tbcols] = $searchio_e[$searchterm];
            }

        return $returnarr;
        }

        if(count($rownumbs)<1){
        return array();
        }

    $returnarr = array();

        foreach ($rownumbs as $rownumb => $rowcount){
        $roworder = abs(5 - $rowcount);

            while(isset($returnarr[$roworder])){
            $roworder++;
            }

        $returnarr[$roworder]=array();

            foreach ($this->cols[$table] as $tbcols){
            $searchio_e = $this->readdb($table, $tbcols);
            $returnarr[$roworder][$tbcols] = $searchio_e[$rownumb];
            }

        $returnarr[$roworder]['id'] = $rownumb;
        }

    return $returnarr;
    }
462150
protected function isContentSearchAttribute($attributeValue)
    {
        return is_array($attributeValue)
            && array_key_exists('contentType', $attributeValue)
            && array_key_exists('choiceType', $attributeValue)
            && array_key_exists('keywords', $attributeValue)
            && isset($attributeValue['contentId']);
    }
199091
public function conditionalAvailabilitySkuSearch(?string $searchString, array $requestParameters = []): ResultSet
    {
        $searchQuery = $this->getFactory()->createConditionalAvailabilitySkuSearchQuery($searchString);
        $searchQuery = $this->expandQuery($searchQuery, $this->getFactory()->getConditionalAvailabilitySkuSearchQueryExpanderPlugins(), $requestParameters);
        $resultFormatters = $this->getFactory()->getConditionalAvailabilitySkuSearchQueryFormatterPlugins();

        return $this->search($searchQuery, $resultFormatters, $requestParameters);
    }
871291
protected function buildUserSearchQuery($searchString = null)
    {
        $builder = $this->createQueryBuilder('u');

        if (!empty($searchString)) {
            $builder
                ->where($builder->expr()->like('u.email', ':searchString'))
                ->orWhere($builder->expr()->like('u.displayName', ':searchString'))
                ->setParameter('searchString', '%' .$searchString . '%');
        }

        return $builder;
    }
1052802
public function getSearchFacetingCountAllFacetsForSelection($defaultIfEmpty = false)
    {
        $countAllFacetsForSelection = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.countAllFacetsForSelection', $defaultIfEmpty);
        return $this->getBool($countAllFacetsForSelection);
    }
671113
public function search($baseDn, $searchFilter, array $attributeList = [])
    {
        $searchResource = ldap_search(
            $this->ldapResource,    // link_identifier
            $baseDn,                // base_dn
            $searchFilter,          // filter
            $attributeList,         // attributes (dn is always returned...)
            0,                      // attrsonly
            0,                      // sizelimit
            10                      // timelimit
        );
        if (false === $searchResource) {
            throw new LdapClientException(
                sprintf(
                    'LDAP error: (%d) %s',
                    ldap_errno($this->ldapResource),
                    ldap_error($this->ldapResource)
                )
            );
        }

        $ldapEntries = ldap_get_entries($this->ldapResource, $searchResource);
        if (false === $ldapEntries) {
            throw new LdapClientException(
                sprintf(
                    'LDAP error: (%d) %s',
                    ldap_errno($this->ldapResource),
                    ldap_error($this->ldapResource)
                )
            );
        }

        return $ldapEntries;
    }
962013
public static function getBySearch($searchQuery, $limit = false, $offset = false, $moreQuerySettings = [])
    {
        return self::getBy(Ajax::SEARCH, $searchQuery, $limit, $offset, $moreQuerySettings);
    }
710012
protected function setSearchResultsAsXml($searchValue, $searchResults)
    {
        $pagePublishTable = $this->getServiceLocator()->get('MelisEngineTablePagePublished');
        $pageLangTbl = $this->getServiceLocator()->get('MelisEngineTablePageLang');
        $cmsLangTbl  = $this->getServiceLocator()->get('MelisEngineTableCmsLang');
        $pageTreeSvc = $this->getServiceLocator()->get('MelisEngineTree');
        $xmlContent = '<?xml version="1.0" encoding="UTF-8"?>';
        $xmlContent.= '<document type="MelisSearchResults" author="MelisTechnology" version="2.0">';
        $xmlContent.= '<searchQuery>'.$searchValue.'</searchQuery>';

        $lastEditedDate = null;
        $pageStatus     = null;
        $totalResults   = 0;

        foreach($searchResults as $result) {

            $pageData = $pagePublishTable->getEntryById($result->page_id)->current();
            $pageLangId = $pageLangTbl->getEntryByField('plang_page_id',(int) $result->page_id )->current();
            $pageUrl    = $pageTreeSvc->getPageLink($result->page_id,true);
            $pageLangId = $pageLangId->plang_lang_id;
            $pageLangLocale = $cmsLangTbl->getEntryById($pageLangId)->current();
            $pageLangLocale = $pageLangLocale->lang_cms_locale;

            if($pageData) {
                $lastEditedDate = $pageData->page_edit_date;
                $pageStatus     = $pageData->page_status;
            }

            $description = $this->limitedText($result->description);

            $xmlContent .= '<result>';
            $xmlContent .= '    <score>' . round($result->score, 2, PHP_ROUND_HALF_EVEN) . '</score>';
            $xmlContent .= '    <pageStatus>' . $pageStatus         .'</pageStatus>';
            $xmlContent .= '    <url>'        . $pageUrl        .'</url>';
            $xmlContent .= '    <pageId>'     . $result->page_id    .'</pageId>';
            $xmlContent .= '    <pageName>'   . $result->page_name  .'</pageName>';
            $xmlContent .= '    <pageLangId>'   . $pageLangId  .'</pageLangId>';
            $xmlContent .= '    <pageLangLocale>'   . $pageLangLocale  .'</pageLangLocale>';
            $xmlContent .= '    <lastPageEdit>' . $lastEditedDate   .'</lastPageEdit>';
            $xmlContent .= '    <description>' .  $description  .'</description>';
            $xmlContent .= '</result>';

            $totalResults++;
        }
        $xmlContent.= '<totalResults>'.$totalResults.'</totalResults>';


        $xmlContent.= '</document>';

        return $xmlContent;
    }
240804
public static function data($searchData, $searchWord, String $output = 'boolean')
    {
        if( ! is_array($searchData) )
        {   
            switch( $output )
            {
                case 'string'  : return strstr($searchData, $searchWord);
                case 'position': return strpos($searchData, $searchWord);
                case 'boolean' : return strpos($searchData, $searchWord) > -1 ? true : false;
                default        : return false;
            }
        }
        else
        {
            $result = array_search($searchWord, $searchData);

            switch( $output )
            {
                case 'string'  : return $result ? $searchWord : false;
                case 'position': return $result ?: -1;
                case 'boolean' : return (bool) $result;
                default        : return false;
            }
        }
    }
510300
public function getFiltered($page, $numRows, $sortAttr, $sortOrder, $searchAttr, $searchValue, $richFilters = [])
    {
        $query = $this->prepareQuery();

        $query = $this->richFiltersOnQuery($query, $richFilters);

        if ($sortAttr && $sortOrder && $this->inScope($sortAttr)) {
            $scope = $this->getScope($sortAttr);
            $query = $query->orderBy($scope, $sortOrder);
        }

        if ($searchAttr && $searchValue && $this->inScope($searchAttr)) {
            $scope = $this->getScope($searchAttr);
            $query = $query->where($scope, 'like', '%' . $searchValue . '%');
        }

        $collection = $query->get();

        $collection = $this->addPermissions($collection);

        $collection = $this->formatCollection($collection);

        $collection = $collection->each(function ($model) {
            $model = $this->formatModel($model);
        });

        if ($sortAttr && $sortOrder && ! $this->inScope($sortAttr)) {
            $collection = $sortOrder == 'asc'
                ? $collection->sortBy($sortAttr)
                : $collection->sortByDesc($sortAttr);
        }

        $collection = $this->richFiltersOnCollection($collection, $richFilters);

        if ($searchAttr && $searchValue && ! $this->inScope($searchAttr)) {
            $collection = $collection->filter(function ($model) use ($searchAttr, $searchValue) {
                $value = (string) $model->$searchAttr;
                $value = strtolower($value);
                $search = strtolower($searchValue);
                return strpos($value, $search) !== false;
            });
        }

        if ($page && $numRows) {
            $toSkip = ($page - 1) * $numRows;
            $count = $collection->count();
            $collection = $collection->take(- ($count - $toSkip))->take($numRows);
        } else if ($numRows)
            $collection = $collection->take($numRows);

        return collect(array_values($collection->toArray()));
    }
1062499
public function getSearchRecommListCount($sSearchStr)
    {
        $iCnt = 0;
        $sSelect = $this->_getSearchSelect($sSearchStr);
        if ($sSelect) {
            $sPartial = substr($sSelect, strpos($sSelect, ' from '));
            $sSelect = "select count( distinct rl.oxid ) $sPartial ";
            $iCnt = \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->getOne($sSelect);
        }

        return $iCnt;
    }
315087
public function search($searchValue, $moduleName, $returnXml = false, string $modulePath = self::FOLDER_PATH)
    {
        $results = [];
        $lucenePath = $modulePath . $moduleName . '/' . self::FOLDER_NAME . '/indexes';

        if (file_exists($lucenePath) && is_readable($lucenePath)) {
            $index = Lucene::open($lucenePath);
            $results = $index->find($searchValue);

            if ($returnXml) {
                $results = $this->setSearchResultsAsXml($searchValue, $results);
            }
        }

        return $results;
    }
1284233
public function search(SearchRequest $searchRequest)
    {
        $resultSet = $this->getInitializedSearchResultSet($searchRequest);
        $this->lastResultSet = $resultSet;

        $resultSet = $this->handleSearchHook('beforeSearch', $resultSet);
        if ($this->shouldReturnEmptyResultSetWithoutExecutedSearch($searchRequest)) {
            $resultSet->setHasSearched(false);
            return $resultSet;
        }

        $query = $this->queryBuilder->buildSearchQuery($searchRequest->getRawUserQuery(), (int)$searchRequest->getResultsPerPage(), $searchRequest->getAdditionalFilters());
        $this->initializeRegisteredSearchComponents($query, $searchRequest);
        $resultSet->setUsedQuery($query);

        // performing the actual search, sending the query to the Solr server
        $query = $this->modifyQuery($query, $searchRequest, $this->search);
        $response = $this->doASearch($query, $searchRequest);

        if ((int)$searchRequest->getResultsPerPage() === 0) {
            // when resultPerPage was forced to 0 we also set the numFound to 0 to hide results, e.g.
            // when results for the initial search should not be shown.
            $response->response->numFound = 0;
        }

        $resultSet->setHasSearched(true);
        $resultSet->setResponse($response);

        $this->getParsedSearchResults($resultSet);

        $resultSet->setUsedAdditionalFilters($this->queryBuilder->getAdditionalFilters());

        /** @var $variantsProcessor VariantsProcessor */
        $variantsProcessor = GeneralUtility::makeInstance(
            VariantsProcessor::class,
            /** @scrutinizer ignore-type */ $this->typoScriptConfiguration,
            /** @scrutinizer ignore-type */ $this->searchResultBuilder
        );
        $variantsProcessor->process($resultSet);

        /** @var $searchResultReconstitutionProcessor ResultSetReconstitutionProcessor */
        $searchResultReconstitutionProcessor = GeneralUtility::makeInstance(ResultSetReconstitutionProcessor::class);
        $searchResultReconstitutionProcessor->process($resultSet);

        $resultSet = $this->getAutoCorrection($resultSet);

        return $this->handleSearchHook('afterSearch', $resultSet);
    }
371523
public function searchCount( Form $form, SearchCriteriaBuilder $searchCriteriaBuilder, $params = array() ) {

        $criteria = $searchCriteriaBuilder->build($form, 0, 0, $params);

        $searchResults = $this->repository->getSearchService()->findContent( $criteria );

        return $searchResults->totalCount;
    }
523867
public function query($searchString)
    {
        $this->searchString = substr(\DB::connection()->getPdo()->quote($searchString), 1, -1);

        return $this;
    }