Perform a regex search on the models immediate fields
@param query:The incoming request query.
@param model: A mongoose model object
@param logger: A logging object
346818
function(query, model, logger) {
    const Log = logger.bind()
    if (query.$term) {
      query.$or = [] // TODO: allow option to choose ANDing or ORing of searchFields/queryableFields
      let queryableFields = this.getQueryableFields(model, Log)
      let stringFields = this.getStringFields(model, Log)

      // EXPL: we can only search fields that are a string type
      queryableFields = queryableFields.filter(function(field) {
        return stringFields.indexOf(field) > -1
      })

      // EXPL: search only specified fields if included
      if (query.$searchFields) {
        if (!Array.isArray(query.$searchFields)) {
          query.$searchFields = query.$searchFields.split(',')
        }

        // EXPL: we can only search fields that are a string type
        query.$searchFields = query.$searchFields.filter(function(field) {
          return stringFields.indexOf(field) > -1
        })

        query.$searchFields.forEach(function(field) {
          let obj = {}
          obj[field] = new RegExp(query.$term, 'i')
          query.$or.push(obj)
        })
      } else {
        queryableFields.forEach(function(field) {
          let obj = {}
          obj[field] = new RegExp(query.$term, 'i')
          query.$or.push(obj)
        })
      }
    }

    delete query.$searchFields
    delete query.$term
  }
260792
@RequestMapping(params = {"query", "hitMaxQueries"})
    public ModelAndView showSearchError(
            PortletRequest request,
            @RequestParam(value = "query") String query,
            @RequestParam(value = "hitMaxQueries") boolean hitMaxQueries) {

        final Map<String, Object> model = new HashMap<>();
        model.put("query", query);
        model.put("hitMaxQueries", hitMaxQueries);

        final boolean isMobile = isMobile(request);
        String viewName = isMobile ? "/jsp/Search/mobileSearch" : "/jsp/Search/search";

        return new ModelAndView(viewName, model);
    }
98448
def _one_to_many_query(cls, query_obj, search4, model_attrib):
        
        model = model_attrib.parent.class_

        already_joined_tables = [mapper.class_ for mapper in query_obj._join_entities]

        if isinstance(search4, (str, int, Iterable)) and model not in already_joined_tables:
            query_obj = query_obj.join(model)

        if isinstance(search4, str):
            query_obj = query_obj.filter(model_attrib.like(search4))

        elif isinstance(search4, int):
            query_obj = query_obj.filter(model_attrib == search4)

        elif isinstance(search4, Iterable):
            query_obj = query_obj.filter(model_attrib.in_(search4))

        return query_obj
994950
function(model, logger) {
    assert(
      model.schema,
      "model not mongoose format. 'schema' property required."
    )
    assert(
      model.schema.paths,
      "model not mongoose format. 'schema.paths' property required."
    )
    assert(
      model.schema.tree,
      "model not mongoose format. 'schema.tree' property required."
    )

    let fields = model.schema.paths
    let fieldNames = Object.keys(fields)

    assert(
      model.routeOptions,
      "model not mongoose format. 'routeOptions' property required."
    )

    for (let i = 0; i < fieldNames.length; i++) {
      let fieldName = fieldNames[i]
      assert(
        fields[fieldName].options,
        "field not mongoose format. 'options' parameter required."
      )
    }

    return true
  }
67702
function modelQuery(options) {
            return models.Post.findOne(options.data, omit(options, ['data']))
                .then((model) => {
                    if (!model) {
                        return Promise.reject(new common.errors.NotFoundError({
                            message: common.i18n.t('errors.api.posts.postNotFound')
                        }));
                    }

                    return {
                        posts: [urlsForPost(model.id, model.toJSON(options), options)]
                    };
                });
        }
134008
private ODocument getModel(String model) {
        String query = String.format("select from Models where %s = ?", OGraphDatabase.LABEL);
        List<ODocument> from = graph.query(new OSQLSynchQuery<ODocument>(query), model);
        if (from.size() > 0) {
            return from.get(0);
        } else {
            return null;
        }
    }
503348
function extractQueryParameters (query) {
  return Object.keys(query.values)
    .reduce((queryParameters, name) => {
      // arrays in routing definitions are not supported
      if (util.isArray(query.values[name])) {
        return queryParameters;
      }

      // escape regular expression characters
      var escaped = query.values[name].replace(EXPRESSION_ESCAPE_REG_EXP, '\\$&');

      // get all occurrences of routing parameters in URI path
      var regExpSource = '^' + escaped.replace(PARAMETER_REG_EXP, URI_QUERY_REPLACEMENT_REG_EXP_SOURCE) + '$';
      var queryParameterMatches = escaped.match(PARAMETER_REG_EXP);

      if (!queryParameterMatches ||
          queryParameterMatches.length === 0) {
        return;
      }

      var parameter = getParameterDescriptor(queryParameterMatches[queryParameterMatches.length - 1]);
      var expression = new RegExp(regExpSource, 'i');
      parameter.map = createUriQueryValueMapper(expression);
      queryParameters[name] = parameter;
      return queryParameters;
    }, Object.create(null));
}
989435
def for_model(self, model):
        
        ct = ContentType.objects.get_for_model(model)
        qs = self.get_queryset().filter(content_type=ct)
        if isinstance(model, models.Model):
            qs = qs.filter(object_pk=force_text(model._get_pk_val()))
        return qs
560622
def query(self, model, **kwargs):
        ''''''
        sm = self.model(model)
        query_class = sm.manager.query_class or Query
        return query_class(sm._meta, self, **kwargs)
326325
public static Query regex(String field,
                              String pattern,
                              int options) {
        return regex(field, pattern, is(options, CASE_INSENSITIVE), is(options, EXTENDED), is(options, MULTILINE), is(options, DOTALL));
    }
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
978966
function validateQuery(query) {
        Validate.isObject(query);
        Validate.notNull(query);
        
        var components = query.getComponents();
        
        for (var i in components.ordering) {
            throw new Error('orderBy and orderByDescending clauses are not supported in the pull query');
        }
        
        if (components.skip) {
            throw new Error('skip is not supported in the pull query');
        }

        if (components.take) {
            throw new Error('take is not supported in the pull query');
        }

        if (components.selections && components.selections.length !== 0) {
            throw new Error('select is not supported in the pull query');
        }

        if (components.includeTotalCount) {
            throw new Error('includeTotalCount is not supported in the pull query');
        }
    }
1022858
function (query) {
        var fieldList = ['name', 'owner', 'description', 'keyword'];
        var parsedField = _.find(fieldList, function (field) {
          return query.indexOf(field + ':') === 0;
        });
        var parsedQuery = parsedField ? query.replace(new RegExp('^' + parsedField + ':'), '') : query;
        return {query: parsedQuery, field: parsedField};
      }
1045256
function(query, params) {
        query = query || '';
        
        // No state
        if(!_current) {
          return false;

        // Use RegExp matching
        } else if(query instanceof RegExp) {
          return !!_current.name.match(query);

        // String; state dot-notation
        } else if(typeof query === 'string') {

          // Cast string to RegExp
          if(query.match(/^\/.*\/$/)) {
            var casted = query.substr(1, query.length-2);
            return !!_current.name.match(new RegExp(casted));

          // Transform to state notation
          } else {
            var transformed = query
              .split('.')
              .map(function(item) {
                if(item === '*') {
                  return '[a-zA-Z0-9_]*';
                } else if(item === '**') {
                  return '[a-zA-Z0-9_\\.]*';
                } else {
                  return item;
                }
              })
              .join('\\.');

            return !!_current.name.match(new RegExp(transformed));
          }
        }

        // Non-matching
        return false;
      }
365198
function(param) {
			this.writeDebug('getQueryString',param);
			if(param) {
				param = param.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
				var regex = new RegExp('[\\?&]' + param + '=([^&#]*)'),
					results = regex.exec(location.search);
				return (results === null) ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
			}
		}
262177
def match(value, query):
    
    if type(query) in [str, int, float, type(None)]:
        return value == query
    elif type(query) == dict and len(query.keys()) == 1:
        for op in query:
            if op == "$eq": return value == query[op]
            elif op == "$lt": return value < query[op]
            elif op == "$lte": return value <= query[op]
            elif op == "$gt": return value > query[op]
            elif op == "$gte": return value >= query[op]
            elif op == "$ne": return value != query[op]
            elif op == "$in": return value in query[op]
            elif op == "$nin": return value not in query[op]
            else: GeoQLError("Not a valid query operator: " + op)
    else:
        raise GeoQLError("Not a valid query: " + str(query))
716243
function Query(model, action, conditions) {
    var self = this;
    self.model = model;
    self.action = action || 'all';
    self.q = {
        conditions: {},
        params: {},
        pkey: false,
        fields: false
    };
    if (typeof conditions === 'object') {
        self.q.conditions = helpers.merge(self.q.conditions, conditions);
    }

    ['all', 'run', 'exec'].forEach(function(method) {
        self[method] = function(params, callback) {
            if (arguments.length === 1) {
                callback = params;
                params = {};
            }
            params = buildQuery(params, this);
            var action = self.action ? self.action : 'all';
            self.model[action](params, callback);
        };
    });

    ['find', 'findOne'].forEach(function(method) {
        self[method] = function(params, callback) {
            if (arguments.length === 1) {
                callback = params;
                params = {};
            }
            params = buildQuery(params, this);
            self.model[method](params, callback);
        };
    });

    ['skip', 'limit', 'order', 'sort', 'group'].forEach(function(method) {
        self[method] = function(key, value) {
            this.q.pkey = false;
            if (method === 'sort') {
                method = 'order';
            }
            if (typeof value === 'undefined') {
                if (/^-/.test(key)) {
                    this.q.params[method] = key.replace(/^-/, '') + ' DESC';
                } else {
                    this.q.params[method] = key;
                }
            } else {
                this.q.params[method] = key + ' ' + value;
            }
            return this;
        };
    });

    self.asc = function(value) {
        this.q.pkey = false;
        this.q.params['order'] = value + ' ASC';
        return this;
    };

    self.desc = function(value) {
        this.q.pkey = false;
        this.q.params['order'] = value + ' DESC';
        return this;
    };

    self.where = function(key, value) {
        if (typeof value === 'undefined') {
            this.q.pkey = key;
        } else {
            this.q.pkey = false;
            this.q.conditions[key] = value;
        }
        return this;
    };

    self.or = function(values) {
        if (Array.isArray(values)) {
            this.q.conditions['or'] = values;
        }
        return this;
    };

    self.range = function(key, from, to) {
        if (typeof to === 'undefined') {
            if (this.q.pkey) {
                to = from;
                from = key;
                if (typeof this.q.conditions[this.q.pkey] === 'undefined') {
                    this.q.conditions[this.q.pkey] = {};
                }
                this.q.conditions[this.q.pkey].gt = from;
                this.q.conditions[this.q.pkey].lt = to;
            }
        } else {
            this.q.pkey = false;
            if (typeof this.q.conditions[key] === 'undefined') {
                this.q.conditions[key] = {};
            }
            this.q.conditions[key].gt = from;
            this.q.conditions[key].lt = to;
        }
        return this;
    };

    ['gt', 'gte', 'lt', 'lte', 'in', 'inq', 'ne', 'neq', 'nin', 'regex', 'like', 'nlike', 'between'].forEach(function(method) {
        self[method] = function(key, value) {
            if (typeof value === 'undefined') {
                if (this.q.pkey) {
                    if (typeof this.q.conditions[this.q.pkey] === 'undefined') {
                        this.q.conditions[this.q.pkey] = {};
                    }
                    this.q.conditions[this.q.pkey][method] = key;
                }
            } else {
                this.q.pkey = false;
                if (typeof this.q.conditions[key] === 'undefined') {
                    this.q.conditions[key] = {};
                }
                this.q.conditions[key][method] = value;
            }
            return this;
        };
    });

    self.slice = function(values) {
        if (Array.isArray(values)) {
            if (typeof values[1] === 'undefined') {
                this.q.params['limit'] = values[0];
            } else {
                this.q.params['skip'] = values[0];
                this.q.params['limit'] = values[1];
            }
        }
        return this;
    };

    /**
     * Destroy records
     * @param {Object} params
     * @param {Function} callback
     */
    self.remove = function(params, callback) {
        if (arguments.length === 1) {
            callback = params;
            params = {};
        }
        params = buildQuery(params, this);
        self.model.remove(params, callback);
    };

    function buildQuery(opts, query) {
        if (typeof opts.where === 'undefined') {
            opts.where = {};
        }
        opts.where = helpers.merge(opts.where, query.q.conditions);
        query.q.conditions = {};

        for (var pkey in query.q.params) {
            if (typeof opts[pkey] === 'undefined') {
                opts[pkey] = {};
            }
            opts[pkey] = query.q.params[pkey];
        }

        query.q.params = {};
        query.q.pkey = false;
        return opts;
    }
}