Search

@param string term

@return stdClass data
430618
public function search($term)
    {
        $url = $this->baseUrl.'/search.php?search='.urlencode($term).'&Submit=Search';

        $parser = $this->parse($url);

        $data = new \stdClass();

        $parser->filter('span.titulo a')->each(function (Crawler $node) use ($data) {
            $data->showUrl = $this->baseUrl.'/'.$node->attr('href');
            $data->showId = substr($node->attr('href'), strrpos($node->attr('href'), '/')+1);
        });

        $data->results = array();

        // Parse all results page
        $parser->filter('table.tabel a')->each(function (Crawler $node) use ($data) {
            $result = new \stdClass();
            $result->title = $node->text();
            $result->url = $this->baseUrl.'/'.$node->attr('href');
            $data->results[] = $result;
        });

        // If show id not found, find an otherway to get it!
        if(!isset($data->showUrl) && count($data->results) > 0) {
            // Query as results, now find the show id
            $result = $data->results[0];

            $parser = $this->parse($result->url);

            $showIds = $parser->filter('table.tabel70 a')->each(function (Crawler $node) use ($data) {
                $href = $node->attr('href');
                if(substr($href, 0, 6) == '/show/') {
                    $showId = substr($href, 6);
                    if(is_numeric($showId)) {
                        return $showId;
                    }
                }
            });

            // Remove NULL values
            $showIds = array_filter($showIds);

            // Take the first id
            foreach($showIds as $showId) {
                if(is_numeric($showId)) {
                    $data->showId = $showId;
                    $data->showUrl = $this->baseUrl.'/show/'.$showId;
                    break;
                }
            }
        }

        return $data;
    }
464698
public function search($query) {
        $found = false;
        if (strpos(strtolower($this->name), $query) !== false) {
            $found = true;
        } else if (strpos(core_text::strtolower($this->visiblename), $query) !== false) {
                $found = true;
            }
        if ($found) {
            $result = new stdClass();
            $result->page     = $this;
            $result->settings = array();
            return array($this->name => $result);
        } else {
            return array();
        }
    }
820662
public function findActiveOrganizations($term = null)
    {
        $qb = $this->createQueryBuilder();
        $qb->distinct('organization')
            ->hydrate(true)
           ->field('status.name')->notIn([ StatusInterface::EXPIRED, StatusInterface::INACTIVE ]);

        $q = $qb->getQuery();
        $r = $q->execute();
        $r = $r->toArray();

        $qb = $this->dm->createQueryBuilder('Organizations\Entity\Organization');
        $qb->field('_id')->in($r);
        if ($term) {
            $qb->field('_organizationName')->equals(new \MongoRegex('/' . addslashes($term) . '/i'));
        }

        $q = $qb->getQuery();
        $r = $q->execute();

        return $r;
    }
1099656
public function hasTerm($taxonomy, $term)
    {
        return isset($this->terms[$taxonomy]) && isset($this->terms[$taxonomy][$term]);
    }
797268
public function docFreq(Zend_Search_Lucene_Index_Term $term)
    {
        $docFreq = 0;

        foreach ($this->_indices as $index) {
            $docFreq += $index->docFreq($term);
        }

        return $docFreq;
    }
905913
private function getSuggestedTerms()
    {
        $terms = array_map(
            function (\Magento\Search\Model\Autocomplete\Item $termItem) {
                return $termItem->getTitle();
            },
            $this->termDataProvider->getItems()
        );

        return $terms;
    }
954897
public function term($phrase = false, $boost = 1.0)
    {
        return function(FieldExpression $expr, LuceneCompiler $compiler) use ($phrase, $boost)
        {
            return new TermExpression($compiler->phrasizeOrTermize($expr->getValue(), $phrase), $boost);
        };
    }
705270
public function search($query)
    {
        $classes = $this->getClassMetadata();
        return $this->_sm->getUnitOfWork()->loadCollection($classes, $query);
    }
708107
public function setSearchTerm($searchTerm)
  {
    if (!is_scalar($searchTerm))
    {
      throw new \Exception("Search term must be a string");
    }

    $this->searchTerm = trim($searchTerm);

    return $this;
  }
168003
public function tokenize($term)
    {
        $stringHelper = $this->container->get('stringcalc_stringhelper');
        $stringHelper->validate($term);
        $term = strtolower($term);

        /** @var InputStreamInterface $inputStream */
        $inputStream = $this->container->get('stringcalc_inputstream');
        $inputStream->setInput($term);

        /** @var StringHelperInterface $stringHelper */
        $stringHelper = $this->container->get('stringcalc_stringhelper');

        $tokenizer = new Tokenizer($inputStream, $stringHelper);

        $tokens = $tokenizer->tokenize();

        return $tokens;
    }
185818
public function hasTerm(Zend_Search_Lucene_Index_Term $term)
    {
        foreach ($this->_indices as $index) {
            if ($index->hasTerm($term)) {
                return true;
            }
        }

        return false;
    }
745298
public function setSearchTerm($term)
    {
        if (!empty($term)) {
            $this->showTree = false;
        }

        $this->searchTerm = $term;
    }
632846
public function getShowId($term)
    {
        $lowerTerm = strtolower($term);

        if (isset($this->searches[$lowerTerm])) {
            return $this->searches[$lowerTerm];
        }

        $searchData = $this->scrapper->search($term);

        if (!isset($searchData->showId)) {
            return;
        }

        $showId = $searchData->showId;

        return $this->searches[$lowerTerm] = $showId;
    }
514396
public function getTermInfo(Zend_Search_Lucene_Index_Term $term)
    {
        $termKey = $term->key();
        if (isset($this->_termInfoCache[$termKey])) {
            $termInfo = $this->_termInfoCache[$termKey];

            // Move termInfo to the end of cache
            unset($this->_termInfoCache[$termKey]);
            $this->_termInfoCache[$termKey] = $termInfo;

            return $termInfo;
        }


        if ($this->_termDictionary === null) {
            $this->_loadDictionaryIndex();
        }

        $searchField = $this->getFieldNum($term->field);

        if ($searchField == -1) {
            return null;
        }
        $searchDicField = $this->_getFieldPosition($searchField);

        // search for appropriate value in dictionary
        $lowIndex = 0;
        $highIndex = count($this->_termDictionary)-1;
        while ($highIndex >= $lowIndex) {
            // $mid = ($highIndex - $lowIndex)/2;
            $mid = ($highIndex + $lowIndex) >> 1;
            $midTerm = $this->_termDictionary[$mid];

            $fieldNum = $this->_getFieldPosition($midTerm[0] /* field */);
            $delta = $searchDicField - $fieldNum;
            if ($delta == 0) {
                $delta = strcmp($term->text, $midTerm[1] /* text */);
            }

            if ($delta < 0) {
                $highIndex = $mid-1;
            } elseif ($delta > 0) {
                $lowIndex  = $mid+1;
            } else {
                // return $this->_termDictionaryInfos[$mid]; // We got it!
                $a = $this->_termDictionaryInfos[$mid];
                $termInfo = new Zend_Search_Lucene_Index_TermInfo($a[0], $a[1], $a[2], $a[3], $a[4]);

                // Put loaded termInfo into cache
                $this->_termInfoCache[$termKey] = $termInfo;

                return $termInfo;
            }
        }

        if ($highIndex == -1) {
            // Term is out of the dictionary range
            return null;
        }

        $prevPosition = $highIndex;
        $prevTerm = $this->_termDictionary[$prevPosition];
        $prevTermInfo = $this->_termDictionaryInfos[$prevPosition];

        $tisFile = $this->openCompoundFile('.tis');
        $tiVersion = $tisFile->readInt();
        if ($tiVersion != (int)0xFFFFFFFE /* pre-2.1 format */  &&
            $tiVersion != (int)0xFFFFFFFD /* 2.1+ format    */) {
            require_once 'Zend/Search/Lucene/Exception.php';
            throw new Zend_Search_Lucene_Exception('Wrong TermInfoFile file format');
        }

        $termCount     = $tisFile->readLong();
        $indexInterval = $tisFile->readInt();
        $skipInterval  = $tisFile->readInt();
        if ($tiVersion == (int)0xFFFFFFFD /* 2.1+ format */) {
            $maxSkipLevels = $tisFile->readInt();
        }

        $tisFile->seek($prevTermInfo[4] /* indexPointer */ - (($tiVersion == (int)0xFFFFFFFD)? 24 : 20) /* header size*/, SEEK_CUR);

        $termValue    = $prevTerm[1] /* text */;
        $termFieldNum = $prevTerm[0] /* field */;
        $freqPointer = $prevTermInfo[1] /* freqPointer */;
        $proxPointer = $prevTermInfo[2] /* proxPointer */;
        for ($count = $prevPosition*$indexInterval + 1;
             $count <= $termCount &&
             ( $this->_getFieldPosition($termFieldNum) < $searchDicField ||
              ($this->_getFieldPosition($termFieldNum) == $searchDicField &&
               strcmp($termValue, $term->text) < 0) );
             $count++) {
            $termPrefixLength = $tisFile->readVInt();
            $termSuffix       = $tisFile->readString();
            $termFieldNum     = $tisFile->readVInt();
            $termValue        = Zend_Search_Lucene_Index_Term::getPrefix($termValue, $termPrefixLength) . $termSuffix;

            $docFreq      = $tisFile->readVInt();
            $freqPointer += $tisFile->readVInt();
            $proxPointer += $tisFile->readVInt();
            if( $docFreq >= $skipInterval ) {
                $skipOffset = $tisFile->readVInt();
            } else {
                $skipOffset = 0;
            }
        }

        if ($termFieldNum == $searchField && $termValue == $term->text) {
            $termInfo = new Zend_Search_Lucene_Index_TermInfo($docFreq, $freqPointer, $proxPointer, $skipOffset);
        } else {
            $termInfo = null;
        }

        // Put loaded termInfo into cache
        $this->_termInfoCache[$termKey] = $termInfo;

        if (count($this->_termInfoCache) == 1024) {
            $this->_cleanUpTermInfoCache();
        }

        return $termInfo;
    }
755723
function get_terms( $value, $taxonomy = 'category' ) {
		
		// load terms in 1 query to save multiple DB calls from following code
		if( count($value) > 1 ) {
			
			$terms = get_terms($taxonomy, array(
				'hide_empty'	=> false,
				'include'		=> $value,
			));
			
		}
		
		
		// update value to include $post
		foreach( array_keys($value) as $i ) {
			
			$value[ $i ] = get_term( $value[ $i ], $taxonomy );
			
		}
		
		
		// filter out null values
		$value = array_filter($value);
		
		
		// return
		return $value;
	}
636426
public function searchDirectory(string $word) {
		$index   = $this->addFilter(new Search($word));
		$content = $this->listDirectories(true);
		$this->removeFilter($index);

		return $content;
	}
934165
public function search(AdminInterface $admin, $term, $page = 0, $offset = 20)
    {
        $datagrid = $admin->getDatagrid();

        $found = false;
        foreach ($datagrid->getFilters() as $filter) {
            /** @var $filter FilterInterface */
            if ($filter->getOption('global_search', false)) {
                $filter->setOption('case_sensitive', $this->caseSensitive);
                $filter->setCondition(FilterInterface::CONDITION_OR);
                $datagrid->setValue($filter->getFormName(), null, $term);
                $found = true;
            }
        }

        if (!$found) {
            return false;
        }

        $datagrid->buildPager();

        $pager = $datagrid->getPager();
        $pager->setPage($page);
        $pager->setMaxPerPage($offset);
        $pager->init();

        return $pager;
    }