@traced
  def search_basenames(self, query):
    """
    Searches index for basenames matching the query.

    Returns (hits, truncated) where:
       hits is an array of basenames that matched.
       truncated is a bool indicated whether not all possible matches were found.
    """
    lower_query = query.lower()

    lower_hits = set()

    max_hits_hint = 25

    # add exact matches first
    trace_begin("exact")
    self.add_all_matching( lower_hits, query, self.get_exact_match_filter(lower_query), max_hits_hint )
    trace_end("exact")

    # add in word starts
    trace_begin("wordstarts")
    self.add_all_wordstarts_matching( lower_hits, query, max_hits_hint )
    trace_end("wordstarts")

    # add in substring matches
    trace_begin("substrings")
    self.add_all_matching( lower_hits, query, self.get_substring_filter(lower_query), max_hits_hint )
    trace_end("substrings")

    # add in superfuzzy matches ONLY if we have no high-quality hit
    has_hq = False
    for lower_hit in lower_hits:
      rank = self._basename_ranker.rank_query(query, lower_hit)
      if 2 > rank:
        has_hq = True
        break
    if not has_hq:
      trace_begin("superfuzzy")
      self.add_all_matching( lower_hits, query, self.get_superfuzzy_filter(lower_query), max_hits_hint )
      trace_end("superfuzzy")

    return lower_hits, len(lower_hits) == max_hits_hint
dataset/ETHPy150Open natduca/quickopen/src/db_index_shard.py/DBIndexShard.search_basenames/swapped operands of `>`