MySQL specific full text search syntax.
330889
function (cols, term, opts) {
            opts = opts || {};
            return format("MATCH %s AGAINST (%s%s)", this.literal(toArray(cols)),
                this.literal(toArray(term).join(" ")), opts.boolean ? " IN BOOLEAN MODE" : "");
        }
1271182
def _filter_exact(self, term, field_name, field_type, is_not):
        
        if field_type == 'text' and field_name not in (DJANGO_CT,):
            term = '^ %s $' % term
            query = self._phrase_query(term.split(), field_name, field_type)
        else:
            query = self._term_query(term, field_name, field_type, stemmed=False)

        if is_not:
            return xapian.Query(xapian.Query.OP_AND_NOT, self._all_query(), query)
        else:
            return query
690519
def search(query)
      regex = Regexp.new(query, 'i')
      _cookbooks.collect do |_, v|
        v[v.keys.first] if regex.match(v[v.keys.first].name)
      end.compact
    end
783459
def raw_query(query, index=INDEX_NAME, doc_type=DOC_TYPE):
    
    result = es_conn.search(index=index, doc_type=DOC_TYPE, body=query)
    return result['hits']['hits']
671837
def highlighted_fulltext(self):
        """"""
        terms = self.fields.get('fulltext', [])
        if not terms:
            return None
        arguments = {'id': self['id'],
                     'query': ' & '.join(terms),
                     }
        with db_connect() as db_connection:
            with db_connection.cursor() as cursor:
                cursor.execute(_read_sql_file('highlighted-fulltext'),
                               arguments)
                hl_fulltext = cursor.fetchone()[0]
        return hl_fulltext
42045
def filter(self, table, keypairs, filter_string):
        """"""
        query = filter_string.lower()
        return [keypair for keypair in keypairs
                if query in keypair.name.lower()]
196276
def match_fields(fields, searches,
                 ignore_case=False, wholename=False, complement=False):
    
    if ignore_case:
        fields = [f.lower() for f in fields]
        searches = [s.lower() for s in searches]
    if wholename:
        match_found = _complete_match
    else:
        match_found = _partial_match

    fields = [(i, field) for i, field in enumerate(fields)]
    matched = []
    for search, (idx, field) in itertools.product(searches, fields):
        if not search:  ## don't return all fields for ''
            continue
        if match_found(search, field) and idx not in matched:
            matched.append(idx)

    if complement:
        matched = [idx for idx in list(zip(*fields))[0] if idx not in matched]

    return matched
107384
def find_by_field(self, table, field, field_value):
        '''
        
        '''
        sql = "select * from {} where {} = '{}'".format(
            table, field, field_value)
        res = self.query(sql)
        return res
20573
def form_query(query_type, query):
    
    fields = [
        field + "^" + str(SEARCH_BOOSTS[field]) if field in SEARCH_BOOSTS else field
        for field in SEARCH_FIELDS
    ]
    return Q("multi_match", fields=fields, query=query, type=query_type)
203599
def search(self, value, createIndex=None):
        ''' 
        '''
        if createIndex:
            self._createIndex = createIndex

        self._search = True
        self.filter(QueryExpression({'$text' : {'$search': value}}))
        return self
1366899
def _search_val(matches, compiled_pattern, fld_val):
        """"""
        mtch = compiled_pattern.search(fld_val)
        if mtch:
            matches.append(fld_val)
456762
function exactOrPrefix(query, node, info) {
  var value

  if (!has(node, info.property)) {
    return false
  }

  value = normalizeValue(node.properties[info.property], info)

  return Boolean(
    value === query.value ||
      (value.slice(0, query.value.length) === query.value &&
        value.charAt(query.value.length) === '-')
  )
}
812414
protected function get_searchsql() {
        global $DB;

        $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
        $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
        $params = array(
            'contextlevel' => CONTEXT_COURSE,
            'fullnamesearch' => '%'.$this->get_search().'%',
            'shortnamesearch' => '%'.$this->get_search().'%'
        );

        $select     = " SELECT c.id, c.fullname, c.shortname, c.visible, c.sortorder ";
        $from       = " FROM {course} c ";
        $where      = " WHERE (".$DB->sql_like('c.fullname', ':fullnamesearch', false)." OR ".
            $DB->sql_like('c.shortname', ':shortnamesearch', false).")";
        $orderby    = " ORDER BY c.sortorder";

        if ($this->currentcourseid !== null && !$this->includecurrentcourse) {
            $where .= " AND c.id <> :currentcourseid";
            $params['currentcourseid'] = $this->currentcourseid;
        }

        return array($select.$ctxselect.$from.$ctxjoin.$where.$orderby, $params);
    }
1082237
function (items, query, fields, exact) {
        var self = this;
        var isTarget = function (fieldName) {
          return fields.indexOf(fieldName) !== -1;
        };
        if (query === '') {
          return items;
        }
        fields = fields || ['name', 'owner', 'description', 'keyword'];
        return _.filter(items, function (item) {
          if ((isTarget('name') && self.matchedInString(query, item.name, exact)) ||
              (isTarget('owner') && self.matchedInString(query, item.owner, exact)) ||
              (isTarget('description') && self.matchedInString(query, item.description, exact)) ||
              (isTarget('keyword') && self.matchedInArray(query, item.keywords, exact))) {
            return true;
          }
          return false;
        });
      }
674186
def decode_mysql_literal(text):
    
    if MYSQL_NULL_PATTERN.match(text):
        return None

    if MYSQL_BOOLEAN_PATTERN.match(text):
        return text.lower() == "true"

    if MYSQL_FLOAT_PATTERN.match(text):
        return float(text)

    if MYSQL_INT_PATTERN.match(text):
        return int(text)

    if MYSQL_STRING_PATTERN.match(text):
        return decode_mysql_string_literal(text)

    raise ValueError("Unable to decode given value: %r" % (text,))
808688
def prettifysql(sql):
    """"""
    pretty = []
    for line in sql.split('\n'):
        pretty.extend(["%s,\n" % x for x in line.split(',')])
    return pretty
215882
private function fulltext_sql_where($value, $mode, $col = 'words', $bool = 'AND')
    {
        $WS = ' ';
        $AS = $col == 'words' ? $WS : self::SEPARATOR;
        $words = $col == 'words' ? rcube_utils::normalize_string($value, true) : array($value);

        $where = array();
        foreach ($words as $word) {
            if ($mode & rcube_addressbook::SEARCH_STRICT) {
                $where[] = '(' . $this->db->ilike($col, $word)
                    . ' OR ' . $this->db->ilike($col, $word . $AS . '%')
                    . ' OR ' . $this->db->ilike($col, '%' . $AS . $word . $AS . '%')
                    . ' OR ' . $this->db->ilike($col, '%' . $AS . $word) . ')';
            }
            else if ($mode & rcube_addressbook::SEARCH_PREFIX) {
                $where[] = '(' . $this->db->ilike($col, $word . '%')
                    . ' OR ' . $this->db->ilike($col, '%' . $AS . $word . '%') . ')';
            }
            else {
                $where[] = $this->db->ilike($col, '%' . $word . '%');
            }
        }

        return count($where) ? '(' . join(" $bool ", $where) . ')' : '';
    }