Add a facet to search results
@return OpenSearchServer\Search\Search
549105
public function facet($field, $min = 0, $multi = false, $postCollapsing = false) {
		if(empty($this->data['facets'])) {
			$this->data['facets'] = array();
		}
		$this->data['facets'][] = array(
			'field' => $field,
			'minCount' => $min,
			'multivalued' => $multi,
			'postCollapsing' => $postCollapsing
		);
		return $this;
	}
711215
protected function addFilters()
    {
        $search = static::$versionTransformer->getSearchValue();
        if ($search != '') {
            $this->addAllFilter($search);
        }
        $this->addColumnFilters();
        return $this;
    }
85365
public function getFacetsByCriteria(Criteria $criteria)
    {
        $query = new Query();
        $query->setSize(0);

        $filter = $this->createFilterFromCriteria($criteria);

        $priorityFacet = new Facet\Terms('priorities');
        $priorityFacet->setField('priority');
        if ($filter->getFilters()) {
            $priorityFacet->setFilter($filter);
        }
        $query->addFacet($priorityFacet);

        $typeFacet = new Facet\Terms('types');
        $typeFacet->setField('type');
        if ($filter->getFilters()) {
            $typeFacet->setFilter($filter);
        }
        $query->addFacet($typeFacet);

        $channelFacet = new Facet\Terms('channels');
        $channelFacet->setField('channel');
        if ($filter->getFilters()) {
            $channelFacet->setFilter($filter);
        }
        $query->addFacet($channelFacet);

        $roleFacet = new Facet\Terms('roles');
        $roleFacet->setField('role');
        if ($filter->getFilters()) {
            $roleFacet->setFilter($filter);
        }
        $query->addFacet($roleFacet);

        $resultSet = $this->getType()->search($query);
        $facets = $resultSet->getFacets();

        $filterSets = [
            'priorities' => array_column($facets['priorities']['terms'], 'term'),
            'types' => array_column($facets['types']['terms'], 'term'),
            'channels' => array_column($facets['channels']['terms'], 'term'),
            'roles' => array_column($facets['roles']['terms'], 'term'),
        ];

        return $filterSets;
    }
638462
private function parseFacetsIntoObjects(SearchResultSet $resultSet)
    {
        // Make sure we can access the facet configuration
        if (!$resultSet->getUsedSearchRequest() || !$resultSet->getUsedSearchRequest()->getContextTypoScriptConfiguration()) {
            return $resultSet;
        }

        // Read the response
        $response = $resultSet->getResponse();
        if (!is_object($response->facet_counts) && !is_object($response->facets)) {
            return $resultSet;
        }

        /** @var FacetRegistry $facetRegistry */
        $facetRegistry = $this->getFacetRegistry();
        $facetsConfiguration = $resultSet->getUsedSearchRequest()->getContextTypoScriptConfiguration()->getSearchFacetingFacets();

        foreach ($facetsConfiguration as $name => $options) {
            if (!is_array($options)) {
                continue;
            }
            $facetName = rtrim($name, '.');
            $type = !empty($options['type']) ? $options['type'] : '';

            $parser = $facetRegistry->getPackage($type)->getParser();
            $facet = $parser->parse($resultSet, $facetName, $options);
            if ($facet !== null) {
                $resultSet->addFacet($facet);
            }
        }

        $this->applyRequirements($resultSet);

        return $resultSet;
    }
956544
public function moveFacetUp(Facet $facet)
    {
        $currentPosition = $facet->getPosition();

        if ($currentPosition < $this->om->count('Claroline\CoreBundle\Entity\Facet\Facet') - 1) {
            $nextPosition = $currentPosition + 1;
            $nextFacet = $this->om
                ->getRepository('ClarolineCoreBundle:Facet\Facet')
                ->findOneBy(array('position' => $nextPosition));
            $nextFacet->setPosition($currentPosition);
            $facet->setPosition($nextPosition);
            $this->om->persist($nextFacet);
            $this->om->persist($facet);
            $this->om->flush();
        }
    }
464186
protected function doFileSearch()
    {
        if (empty($this->searchLocations)) {
            throw new \RuntimeException(
                'No search locations have been defined.'
            );
        }

        return (new Finder())
            ->name($this->searchPattern)
            ->in($this->searchLocations)
            ->depth($this->searchDepth)
            ->files();
    }
980523
public function googleSearch()
    {
        $search = new \Municipio\Search\Google(get_search_query(), $this->getIndex());
        $this->data['search'] = $search;
        $this->data['results'] = $search->results;
    }
257330
public function getSearchFaceting($defaultIfEmpty = false)
    {
        $isFacetingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting', $defaultIfEmpty);
        return $this->getBool($isFacetingEnabled);
    }
800964
public function editFacetAction(Facet $facet)
    {
        $oldName = $facet->getName();
        $form = $this->formFactory->create(new FacetType(), $facet);
        $form->handleRequest($this->request);

        if ($form->isValid()) {
            $facet = $this->facetManager->editFacet($facet, $form->get('name')->getData(), $form->get('forceCreationForm')->getData());

            return new JsonResponse(
                array(
                    'id' => $facet->getId(),
                    'name' => $facet->getName()
                )
            );
        }

        return $this->render(
            'ClarolineCoreBundle:Administration\Facet:editFacetForm.html.twig',
            array('form' => $form->createView(), 'facet' => $facet)
        );
    }
826923
public function help()
	{
		$this
			->output
			->addOverview(
				'Run a solr search migration. Searches for and indexes models with the searcable interface.'
			)
			->addTasks($this)
			->addArgument(
				'-url: the base url of the site being indexed.',
				'Example: -url=\'https://localhost\''
			)
			->addArgument(
				'-components: component(s) that should be indexed.',
				'If multiple, separate each component name with a comma.',
				'Example: -components=\'blog, content, kb, resources\''
			)
			->addArgument(
				'--all: index all searchable components',
				'Any component that contains a model that implements Searchable will be added to the solr index.',
				'Example: --all'
			)
			->addArgument(
				'--rebuild: include components that have already had a full index run previously.',
				'this will overwrite any existing search documents with a new version.',
				'example: --rebuild'
			);
	}
650943
public function modifyQuery(Query $query)
    {
        $typoScriptConfiguration = $this->searchRequest->getContextTypoScriptConfiguration();
        $faceting = FacetingBuilder::fromTypoScriptConfiguration($typoScriptConfiguration);

        $allFacets = $typoScriptConfiguration->getSearchFacetingFacets();
        $facetParameters = $this->buildFacetingParameters($allFacets, $typoScriptConfiguration);
        foreach ($facetParameters as $facetParameter => $value) {
            if(strtolower($facetParameter) === 'facet.field') {
                $faceting->setFields($value);
            } else {
                $faceting->addAdditionalParameter($facetParameter, $value);
            }
        }

        $searchArguments = $this->searchRequest->getArguments();
        if (!is_array($searchArguments)) {
            return $query;
        }

        $keepAllFacetsOnSelection = $typoScriptConfiguration->getSearchFacetingKeepAllFacetsOnSelection();
        $facetFilters = $this->addFacetQueryFilters($searchArguments, $allFacets, $keepAllFacetsOnSelection);

        $queryBuilder = new QueryBuilder($typoScriptConfiguration);
        $queryBuilder->startFrom($query)->useFaceting($faceting)->useFilterArray($facetFilters);
        return $query;
    }
51140
public function search()
	{
		preg_match_all('/\[[^\]]*\]/', $this->str, $this->matches);		

		// Format matches
		if(!empty($this->matches))
		{
			$this->matches = $this->matches[0];
			$this->format();
		}

		return $this;
	}
173205
public function setFacet($name)
    {
        if ($this->getSearchParam('facet') === null) {
            $this->setSearchParams('facet', 'true');
        }

        $this->setSearchParams('facet.field', $name);

        return $this;
    }
1197011
def add_term_facet(self, *args, **kwargs):
        """"""
        self.facets.append(TermFacet(*args, **kwargs))
406555
protected function addFacebook()
	{
		// Get default Site Name
		$sitename = $this->getConfig('title.sitename');

		// Get value for title tag
		$title = $this->renderTitle();

		// Get value of description
		$description = ($this->description) ? $this->description : $this->getConfig('description');

		// Get Default values in config file
		$admins = $this->getConfig('facebook.admins');
		$page_id = $this->getConfig('facebook.page_id');
		$app_id = $this->getConfig('facebook.app_id');
		$image = $this->getConfig('facebook.image');

		// Check if option is active
		if ($this->getConfig('facebook.active'))
		{
			// Don't override a value set manually
			if (!array_key_exists('fb:page_id', $this->meta['property']))
			{
				$this->addOneMeta('property', 'fb:page_id', $page_id);
			}

			// Don't override a value set manually
			if (!array_key_exists('fb:app_id', $this->meta['property']))
			{
				$this->addOneMeta('property', 'fb:app_id', $app_id);
			}

			// Don't override a value set manually
			if (!array_key_exists('fb:admins', $this->meta['property']))
			{
				$this->addOneMeta('property', 'fb:admins', $admins);
			}

			// Don't override a value set manually + check if file exists
			if (File::isFile(public_path($image)) && !array_key_exists('og:image', $this->meta['property']))
			{
				$this->addOneMeta('property', 'og:image', $image);
			}

			// Don't override a value set manually
			if (!array_key_exists('og:url', $this->meta['property']))
			{
				$this->addOneMeta('property', 'og:url', URL::current());
			}

			// Don't override a value set manually
			if (!array_key_exists('og:type', $this->meta['property']))
			{
				$this->addOneMeta('property', 'og:type', 'website');
			}

			// Don't override a value set manually
			if (!array_key_exists('og:site_name', $this->meta['property']))
			{
				$this->addOneMeta('property', 'og:site_name', $sitename);
			}

			// Don't override a value set manually
			if (!array_key_exists('og:title', $this->meta['property']))
			{
				$this->addOneMeta('property', 'og:title', $title);
			}

			// Don't override a value set manually
			if (!array_key_exists('og:description', $this->meta['property']))
			{
				$this->addOneMeta('property', 'og:description', $description);
			}
		}

		// Option is inactive
		else
		{
			$this->killFacebook();
		}
	}
1296466
public function showSearch() {
		$datas = $this->sources;
		$select = '';
		$select = '<label for="'.$this->htmlId().'">'.$this->label().': </label>'.
				  '<select id="'.$this->htmlId().'" class="'.$this->htmlClasses().'" name="'.$this->name().'[]'.'" multiple>';
		foreach ($datas as $label => $data){
			$select .= '<option value="'.$data.'"'.((is_array($this->val))
				? ((in_array($data, $this->val)) ? 'selected' : '')
				: '').'>'.$label.'</option>';
		}
		$select .= '</select>';
		return $select;
	}
265777
public function addTermEntry()
    {
        include_once 'Zend/Search/Lucene/Search/QueryEntry/Term.php';
        $entry = new Zend_Search_Lucene_Search_QueryEntry_Term($this->_currentToken->text, $this->_context->getField());
        $this->_context->addEntry($entry);
    }