Search for files and folders.

 @param [String] path
 @param [String] query
 @param [Integer] start
 @param [Integer] max_results
 @param [String] mode
 @return [Array<Dropbox::Metadata>] matches
335890
def search(path, query, start=0, max_results=100, mode='filename')
      resp = request('/files/search', path: path, query: query, start: start,
        max_results: max_results, mode: mode)
      matches = resp['matches'].map { |m| parse_tagged_response(m['metadata']) }
      return matches
    end
1241481
public Map<Path,List<LineMatches>> find(String search) throws IOException {
        count = 0;
        Pattern pattern = Pattern.compile(search);
        Map<Path,List<LineMatches>> fileMatches = new LinkedHashMap<>();
        Files.walkFileTree(root,
            EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<Path>() {
                public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException {
                    for (PathMatcher matcher : matchers) {
                        if (matcher.matches(path)) {
                            List<LineMatches> lineMatches = search(path, pattern);
                            if (lineMatches != null)
                                fileMatches.put(root.relativize(path), lineMatches);
                        }
                    }
                    return count == 0 || count < limit ? FileVisitResult.CONTINUE : FileVisitResult.TERMINATE;
                }
            }
        );

        return fileMatches;
    }
646805
function(path, params) {
        var queryString = this.query_string;
        for (var param in params) {
            var re = new RegExp(":"+ param)
            var found = false;
            if (path.search(re) != -1) {
                path = path.replace(re, params[param]);
                found = true;
            }
            for (var query in queryString) {
                if (queryString[query].search
                    && queryString[query].search(re) != -1) {
                    queryString[query] = queryString[query].replace(re, params[param]);
                    found = true;
                }
            }
            // exclude params in headers
            for (var header in this.headers) {
                if (this.headers[header].search(re) != -1) {
                    found = true;
                }
            }
            if (!found)
                queryString[param] = params[param];
        }
        var query = querystring.stringify(queryString);
        return path + ((query != "") ? "?"+ query : "");
    }
334392
function Match(path, route, match, query, valueDecoders) {
  this.path = path;
  this.route = route;
  this.match = match;
  this.query = query;

  if (valueDecoders) {
    Object.keys(match || {}).forEach(function(key) {
      if (typeof valueDecoders === 'function') {
        match[key] = valueDecoders(key, match[key]);
        return;
      }
      var fn = valueDecoders.hasOwnProperty(key) && valueDecoders[key];
      if (typeof fn === 'function') {
        match[key] = fn(match[key]);
      }
    });
  }

  this.unmatchedPath = this.match && this.match._ ?
    this.match._[0] :
    null;

  this.matchedPath = this.unmatchedPath ?
    this.path.substring(0, this.path.length - this.unmatchedPath.length) :
    this.path;
}
542618
async def query(self, path, method='get', **params):
        
        if method in ('get', 'post', 'patch', 'delete', 'put'):
            full_path = self.host + path
            if method == 'get':
                resp = await self.aio_sess.get(full_path, params=params)
            elif method == 'post':
                resp = await self.aio_sess.post(full_path, data=params)
            elif method == 'patch':
                resp = await self.aio_sess.patch(full_path, data=params)
            elif method == 'delete':
                resp = await self.aio_sess.delete(full_path, params=params, headers=params)
            elif method == 'put':
                resp = await self.aio_sess.put(full_path, data=params)

            async with resp:
                # return the content if its a binary one
                if resp.content_type.startswith('application/pdf') or \
                        resp.content_type.startswith('application/epub'):
                    return await resp.read()

                return await self.handle_json_response(resp)
        else:
            raise ValueError('method expected: get, post, patch, delete, put')
830266
function matchRoutes(routes, path, query) {
  query = query === undefined ? {} : isString(query) ? qs.parse(query) : query;
  return matchRoutesImpl(routes, path, query);
}
1145395
function (search) {
            var result = false;

            files.forEach(function (elem) {
                if (elem.path === search) {
                    result = true;
                }
            });
            
            return result;
        }
295865
function search(query, cols, max) {
    var url;
    var token = cache.get('token');
    var cases;
    var fields;
    var dfrd = Q.defer();

    function extractCases(xml) {
      var r = _parse(xml, dfrd);
      if (!r ||
        !r.response ||
        !r.response.cases ||
        !r.response.cases.length ||
        !r.response.cases[0].case) {
        return dfrd.reject(MODULE_ERRORS.bugNotFound);
      }
      cases = r.response.cases[0].case.map(function(kase) {
        var bug = new Case({
          id: kase.$.ixBug,
          operations: kase.$.operations.split(','),
          title: kase.sTitle[0].trim(),
          status: kase.sStatus[0].trim(),
          url: format('%s://%s/default.asp?%s', PROTOCOL, conf.host,
            kase.$.ixBug),
          fixFor: kase.sFixFor[0].trim()
        });
        if (kase.sPersonAssignedTo) {
          bug.assignedTo = kase.sPersonAssignedTo[0].trim();
          bug.assignedToEmail = kase.sEmailAssignedTo[0].trim();
        }
        if (kase.tags && kase.tags[0].tag) {
          bug.tags = kase.tags[0].tag.join(', ');
        }
        // find anything leftover in the case, disregarding the fields we
        // already
        _(kase)
          .keys()
          .difference(_.keys(bug).concat('sTitle', 'sStatus', '$',
            'sFixFor', 'sPersonAssignedTo',
            'sEmailAssignedTo'))
          .each(function(key) {
            var value = kase[key];
            bug[key] = _.isArray(value) && value.length === 1 ?
              // dereference
              bug[key] = value[0].trim() :
              value;
          });
        bug._raw = kase;
        return bug;
      });
      if (cases.length > 1) {
        return cases;
      }
      return cases[0];
    }

    fields = (cols || DEFAULT_COLS).join(',');
    max = max || DEFAULT_MAX;
    query = encodeURIComponent(query);
    if (!token) {
      dfrd.reject(MODULE_ERRORS.undefinedToken);
    } else {
      url = format(URLs.search, PROTOCOL, conf.host, query, fields, max,
        token);
      request(url, function(err, res, body) {
        var newCases;
        if (err) {
          dfrd.reject(err);
        } else {
          newCases = extractCases(body);
          if (!newCases) {
            console.error(body);
            dfrd.reject(MODULE_ERRORS.unknown);
          } else {
            dfrd.resolve(newCases);
          }
        }
      });
    }
    return dfrd.promise;
  }
964676
public List findByQuery(String query, Map<Parameter, Object> parameterMap, int firstResult, int maxResult)
    {
        s = getStatelessSession();

        Query q = s.createQuery(query);
        q.setFirstResult(firstResult);
        q.setMaxResults(maxResult);

        setParameters(parameterMap, q);

        return q.list();
    }
423604
def search(query)
      return [] if query.nil?

      @atoms = @storage.fetch(cleanup_atoms(query), query[/\^/])
      queries = parse_query(query.dup)
      positive = run_queries(queries[:positive])
      positive_quoted = run_quoted_queries(queries[:positive_quoted])
      negative = run_queries(queries[:negative])
      negative_quoted = run_quoted_queries(queries[:negative_quoted])
      starts_with = run_queries(queries[:starts_with], true)
      start_quoted = run_quoted_queries(queries[:start_quoted], true)

      results = ActiveSupport::OrderedHash.new

      if queries[:start_quoted].any?
        results = merge_query_results(results, start_quoted)
      end

      if queries[:starts_with].any?
        results = merge_query_results(results, starts_with)
      end

      if queries[:positive_quoted].any?
        results = merge_query_results(results, positive_quoted)
      end

      if queries[:positive].any?
        results = merge_query_results(results, positive)
      end

      negative_results = (negative.keys + negative_quoted.keys)
      results.delete_if { |r_id, w| negative_results.include?(r_id) }
      results
    end
710053
def find(self, path, all=False):
        
        matches = []
        for elem in chain(settings.STYLESHEETS.values(), settings.JAVASCRIPT.values()):
            if normpath(elem['output_filename']) == normpath(path):
                match = safe_join(settings.PIPELINE_ROOT, path)
                if not all:
                    return match
                matches.append(match)
        return matches
740007
def find(self, path, all=False):
        
        try:
            start, _, extn = path.rsplit('.', 2)
        except ValueError:
            return []
        path = '.'.join((start, extn))
        return find(path, all=all) or []
940280
def search(query, options={})
      params = { :query => query, :lang => @query_options[:lang], :limit => @query_options[:limit] }.merge(options)
      response = get(surl('search'), params, format: :json)
      response['result']
    end
967717
def build_query(path, details)
        query = @pattern.dup

        prefix = path.prefix.empty? ? "" : "#{escape_entry(path.prefix)}\\1"
        query.gsub!(/:prefix(\/)?/, prefix)

        partial = escape_entry(path.partial? ? "_#{path.name}" : path.name)
        query.gsub!(/:action/, partial)

        details.each do |ext, candidates|
          if ext == :variants && candidates == :any
            query.gsub!(/:#{ext}/, "*")
          else
            query.gsub!(/:#{ext}/, "{#{candidates.compact.uniq.join(',')}}")
          end
        end

        File.expand_path(query, @path)
      end
630289
def search(index, query, snippet_folder=SNIPPET_FOLDER, term_freq=term_freq):
    
    fallback_log = []
    code_list = []
    tokens = tokenize(query)
    tokens, abbr_log = abbr_expand(tokens)
    tokens, correct_log = correct(tokens, term_freq)
    tokens = lemmatize(tokens)
    tokens = filterout(tokens)
    while len(tokens) > 0: # Fallback mechanism
        code_list = fetch(index, tokens)
        if len(code_list) > 0:
            break
        tokens.sort(key=lambda tk:len(index.get(tk, [])))
        remove = tokens.pop()
        fallback_log.append(remove)
    snippets = get_snippets(code_list, snippet_folder)
    hints, hint_scores = get_hints(code_list, current_tokens=tokens)
    response = list(zip(code_list, snippets))
    response.sort(key=result_sort_key, reverse=True)

    # Count search_frequency
    if len(response) <= MAX_RESULT: # the respone can be shown in one page
        search_freq.update(code_list)
        with open(SEARCH_FREQ_JSON, 'w') as f:
            json.dump(search_freq, f, indent=2)

    return response, tokens, hints, hint_scores, \
           abbr_log, correct_log, fallback_log
1171577
public SearchResult getSuggestions(StaplerRequest req, String query) {
        Set<String> paths = new HashSet<>();  // paths already added, to control duplicates
        SearchResultImpl r = new SearchResultImpl();
        int max = req.hasParameter("max") ? Integer.parseInt(req.getParameter("max")) : 100;
        SearchableModelObject smo = findClosestSearchableModelObject(req);
        for (SuggestedItem i : suggest(makeSuggestIndex(req), query, smo)) {
            if(r.size()>=max) {
                r.hasMoreResults = true;
                break;
            }
            if(paths.add(i.getPath()))
                r.add(i);
        }
        return r;
    }
591587
public static List<Path> getSubDirectoryPathList(Path startDirectoryPath,
			Predicate<Path> filter) {
		return getSubPathList(startDirectoryPath, Integer.MAX_VALUE,
				DirectoryAndNotSymbolicLinkFilter.and(filter));
	}