Generate search query using tag and category tables.
519095
public static function findPageForSearch( $config = [] ) {

		// Search
		$searchContent	= isset( $config[ 'searchContent' ] ) ? $config[ 'searchContent' ] : false;
		$keywordsParam	= isset( $config[ 'search-param' ] ) ? $config[ 'search-param' ] : 'keywords';

		$keywords = Yii::$app->request->getQueryParam( $keywordsParam );

		// Sort
		$ratingComment	= isset( $config[ 'ratingComment' ] ) ? $config[ 'ratingComment' ] : false;
		$ratingReview	= isset( $config[ 'ratingReview' ] ) ? $config[ 'ratingReview' ] : false;

		// Filters
		$optionFilters	= isset( $config[ 'optionFilters' ] ) ? $config[ 'optionFilters' ] : [];

		$modelClass	= static::$modelClass;
		$modelTable	= $modelClass::tableName();
		$parentType	= static::$parentType;

		// Search
		if( $searchContent && isset( $keywords ) ) {

			$cache = CacheProperties::getInstance()->isCaching();

			// Search in model cache - full search
			if( $cache ) {

				$config[ 'search-col' ][] = "$modelTable.gridCache";
			}
			// Search in model content only
			else {

				// Search Query
				$config[ 'query' ] = isset( $config[ 'query' ] ) ? $config[ 'query' ] : $modelClass::queryWithAll( [ 'relations' => [ 'modelContent', 'modelContent.template' ] ] );

				// Search in model content
				$config[ 'search-col' ][] = 'modelContent.content';
			}
		}

		// Sort
		$sortParam	= Yii::$app->request->get( 'sort' );
		$sortParam	= preg_replace( '/-/', '', $sortParam );

		// Sort using ModelComment Table
		if( ( $ratingComment || $ratingReview ) && $sortParam == 'rating' ) {

			$type	= '';
			$query	= $config[ 'query' ];

			// Sort by Rating using comments available in ModelComment table
			if( $ratingComment ) {

				$type = ModelComment::TYPE_COMMENT;
			}
			// Sort by Rating using reviews available in ModelComment table
			else if( $ratingReview ) {

				$type = ModelComment::TYPE_REVIEW;
			}

			$commentTable	= Yii::$app->factory->get( 'modelCommentService' )->getModelTable();
			$approved		= ModelComment::STATUS_APPROVED;

			$query->leftJoin( $commentTable,
				"$commentTable.parentId=$modelTable.id AND $commentTable.parentType='$parentType' AND
				$commentTable.type='$type' AND $commentTable.status=$approved" );
		}

		// Option Filters
		if( count( $optionFilters ) > 0 ) {

			$query = $config[ 'query' ];

			$optionTable	= Yii::$app->factory->get( 'optionService' )->getModelTable();
			$mOptionTable	= Yii::$app->factory->get( 'modelOptionService' )->getModelTable();

			foreach( $optionFilters as $key => $option ) {

				$optionList = static::getOptions( $option );

				if( count( $optionList ) > 0 ) {

					$query->leftJoin( "$mOptionTable AS MC$key", "$modelTable.id=MC$key.parentId AND MC$key.parentType='$parentType'" )
						->leftJoin( "$optionTable AS O$key", "MC$key.modelId=O$key.id" )
						->andWhere( "MC$key.active=1" );

					$config[ 'filters' ][] = [ 'in', "O$key.id", $optionList ];
				}
			}
		}

		return parent::findPageForSearch( $config );
	}
1226422
def search(query, catalog=_marker):
    

    # query needs to be a dictionary
    if not isinstance(query, dict):
        fail("Catalog query needs to be a dictionary")

    # Portal types to query
    portal_types = query.get("portal_type", [])
    # We want the portal_type as a list
    if not isinstance(portal_types, (tuple, list)):
        portal_types = [portal_types]

    # The catalogs used for the query
    catalogs = []

    # The user did **not** specify a catalog
    if catalog is _marker:
        # Find the registered catalogs for the queried portal types
        for portal_type in portal_types:
            # Just get the first registered/default catalog
            catalogs.append(get_catalogs_for(
                portal_type, default="portal_catalog")[0])
    else:
        # User defined catalogs
        if isinstance(catalog, (list, tuple)):
            catalogs.extend(map(get_tool, catalog))
        else:
            catalogs.append(get_tool(catalog))

    # Cleanup: Avoid duplicate catalogs
    catalogs = list(set(catalogs)) or [get_portal_catalog()]

    # We only support **single** catalog queries
    if len(catalogs) > 1:
        fail("Multi Catalog Queries are not supported!")

    return catalogs[0](query)
1272056
def search(self, query, fields=None, page=1, max_records=None, flatten=True):
        """"""
        if fields is None:
            fields = []
        page = int(page)
        pages = float('inf')
        data = {
            "query": query,
            "page": page,
            "fields": fields,
            "flatten": flatten
        }

        count = 0
        while page <= pages:
            payload = self._post(self.search_path, data=data)
            pages = payload['metadata']['pages']
            page += 1
            data["page"] = page

            for result in payload["results"]:
                yield result
                count += 1
                if max_records and count >= max_records:
                    return
1347040
protected function getTagsFromMySQL()
    {
        $queryParts = $this->getQueryParts();

        $queryBuilder = self::getQueryBuilder('tx_kesearch_index');
        $queryBuilder->getRestrictions()->removeAll();

        $tagRows = $queryBuilder
            ->select('tags')
            ->from($queryParts['FROM'])
            ->add('where', $queryParts['WHERE'])
            ->execute()
            ->fetchAll();

        return array_map(
            function ($row) {
                return $row['tags'];
            },
            $tagRows
        );
    }
1207725
def search(self, query, delegate, args=None, extra_args=None):
        """"""
        if args is None:
            args = {}
        args['q'] = query
        return self.__doDownloadPage(self.search_url + '?' + self._urlencode(args),
            txml.Feed(delegate, extra_args), agent=self.agent)
1213139
def blog__get_categories(
      order: nil,
      language: nil,
      search: nil,
      page: nil,
      per_page: nil
    )
      categories = LatoBlog::Category.all

      # apply filters
      order = order && order == 'ASC' ? 'ASC' : 'DESC'
      categories = _categories_filter_by_order(categories, order)
      categories = _categories_filter_by_language(categories, language)
      categories = _categories_filter_search(categories, search)

      # take categories uniqueness
      categories = categories.uniq(&:id)

      # save total categories
      total = categories.length

      # manage pagination
      page = page&.to_i || 1
      per_page = per_page&.to_i || 20
      categories = core__paginate_array(categories, per_page, page)

      # return result
      {
        categories: categories && !categories.empty? ? categories.map(&:serialize) : [],
        page: page,
        per_page: per_page,
        order: order,
        total: total
      }
    end
167857
def search(self, tags=None):
        
        if isinstance(tags, str):
            tags = [tags]
        return self.workbench.generate_sample_set(tags)
1167839
def _generate_query_analysis(self, parsed_query, db_name, collection_name):
        """"""

        analyzed_fields = []
        field_count = 0
        supported = True
        sort_fields = []
        query_mask = None

        if 'command' in parsed_query and parsed_query['command'] not in SUPPORTED_COMMANDS:
            supported = False
        else:
            #if 'orderby' in parsed_query:
            sort_component = parsed_query['orderby'] if 'orderby' in parsed_query else []
            sort_seq = 0
            for key in sort_component:
                sort_field = {'fieldName': key,
                              'fieldType': SORT_TYPE,
                              'seq': sort_seq}
                sort_fields.append(key)
                analyzed_fields.append(sort_field)
                field_count += 1
                sort_seq += 1

            query_component = parsed_query['query'] if 'query' in parsed_query else {}
            for key in query_component:
                if key not in sort_fields:
                    field_type = UNSUPPORTED_TYPE
                    if ((key not in UNSUPPORTED_QUERY_OPERATORS) and
                            (key not in COMPOSITE_QUERY_OPERATORS)):
                        try:
                            if query_component[key] == {}:
                                raise
                            nested_field_list = query_component[key].keys()
                        except:
                            field_type = EQUIV_TYPE
                        else:
                            for nested_field in nested_field_list:
                                if ((nested_field in RANGE_QUERY_OPERATORS) and
                                    (nested_field not in UNSUPPORTED_QUERY_OPERATORS)):
                                    field_type = RANGE_TYPE
                                else:
                                    supported = False
                                    field_type = UNSUPPORTED_TYPE
                                    break

                    if field_type is UNSUPPORTED_TYPE:
                        supported = False

                    analyzed_field = {'fieldName': key,
                                      'fieldType': field_type}
                    analyzed_fields.append(analyzed_field)
                    field_count += 1

        query_mask = parsed_query['queryMask']

        # QUERY ANALYSIS
        return OrderedDict({
            'analyzedFields': analyzed_fields,
            'fieldCount': field_count,
            'supported': supported,
            'queryMask': query_mask
        })
742766
public static function generateSearchQuery( $columns, $searchTerms ) {

		$searchTerms	= preg_split( '/,/', $searchTerms );
		$searchQuery	= "";

		// Multiple columns
		if( is_array( $columns ) ) {

			foreach( $columns as $ckey => $column ) {

				$query	= null;

				foreach( $searchTerms as $skey => $term ) {

					if( $skey  == 0 ) {

						$query = " $column like '%$term%' ";
					}
					else {

						$query .= " OR $column like '%$term%' ";
					}
				}

				if( isset( $query ) ) {

					if( $ckey  == 0 ) {

						$searchQuery =	"( $query )";
					}
					else {

						$searchQuery .= " OR ( $query )";
					}
				}
			}
		}
		// Single column
		else {

			foreach( $searchTerms as $key => $value ) {

				if( $key  == 0 ) {

					$searchQuery .= " $columns like '%$value%' ";
				}
				else {

					$searchQuery .= " OR $columns like '%$value%' ";
				}
			}
		}

		return $searchQuery;
	}
718597
def query(self, search, query):
        '''
        
        '''
        if not query:
            return search

        included, excluded = [], []
        for term in query.split(' '):
            if not term.strip():
                continue
            if term.startswith('-'):
                excluded.append(term[1:])
            else:
                included.append(term)
        if included:
            search = search.query(self.multi_match(included))
        for term in excluded:
            search = search.query(~self.multi_match([term]))
        return search
471116
def add_tags(alert_ids, tags)
      query = generate_query_params(alertIds: alert_ids, tags: tags)
      http_put('/tags' + query, {})
    end
405858
public function tag_search_page($query = '', $tagcollid = 0) {
        $rv = $this->output->heading(get_string('searchtags', 'tag'), 2);

        $searchbox = $this->search_form($query, $tagcollid);
        $rv .= html_writer::div($searchbox, '', array('id' => 'tag-search-box'));

        $tagcloud = core_tag_collection::get_tag_cloud($tagcollid, false, 150, 'name', $query);
        $searchresults = '';
        if ($tagcloud->get_count()) {
            $searchresults = $this->output->render_from_template('core_tag/tagcloud',
                    $tagcloud->export_for_template($this->output));
            $rv .= html_writer::div($searchresults, '', array('id' => 'tag-search-results'));
        } else if (strval($query) !== '') {
            $rv .= '<div class="tag-search-empty">' . get_string('notagsfound', 'tag', s($query)) . '</div>';
        }

        return $rv;
    }
439635
def search(ctx, tags, prefix=None):
    '''
    
    '''

    _generate_api(ctx)

    for i, match in enumerate(ctx.obj.api.search(*tags, prefix=prefix)):

        click.echo(match, nl=False)
        print('')
461101
function () {
  var cats = getCategories();
  for (var i in cats) {
    log.debug('\n\nTEST CATEGORY: ' + cats[i]);
    testCategory(cats[i]);
  }
}
1114586
public function scopeByTagNames($query, $tag_names)
	{
		$normalize_tag_names = [];
		foreach ($tag_names as $tag_name) {
			// mormalize string
			$normalize_tag_names[] = app(TaggingUtility::class)->normalizeTagName(trim($tag_name));
		}
		return $query->whereIn('name', $normalize_tag_names);
	}
1077831
def search(self, query, page=0, order=7, category=0, multipage=False):
        
        search = Search(self.base_url, query, page, order, category)
        if multipage:
            search.multipage()
        return search
833666
def generate_entry_tags(sender, instance, created, raw, using, **kwargs):
    """"""
    Tag.objects.create_tags(instance)