Zoekt search results as_json defaults should pull from multi-match constants

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Background

The as_json method has defaults specified but these defaults should be pulled from existing constants in the codebase. Additionally we should make sure appropriate values from the BlobSearchResolver are passed down

      def as_json
        {
          version: 2,
          timeout: options.fetch(:timeout, '120s'),
          num_context_lines: options.fetch(:num_context_lines, 20),
          max_file_match_window: options.fetch(:max_file_match_window, 1000),
          max_file_match_results: options.fetch(:max_file_match_results, 5),
          max_line_match_window: options.fetch(:max_line_match_window, 500),
          max_line_match_results: options.fetch(:max_line_match_results, 10),
          max_line_match_results_per_file: options.fetch(:max_line_match_results_per_file, 3),
          forward_to: use_traversal_id_queries? ? build_node_queries : build_node_queries_from_targets
        }
      end

Proposal

Replace the following values with their respective constants (or create new constants somewhere, this file would be a good starting point):

  • num_context_lines
    • corresponds to "this many number of context lines will be added before and after each matched line." (see NumContextLines in zoekt).
    • the MultiMatch class is hardcoded to show 2 lines before & 2 lines after maximum.
    • Search::Zoekt::Client: This set with CONTEXT_LINES_COUNT.
    • default is 20 but should use the default from MultiMatch constant: NEW_CHUNK_THRESHOLD instead of 20
  • max_file_match_window
  • max_file_match_results - this is an internal field from the gitlab zoekt indexer.
  • max_line_match_window - this is an internal field from the gitlab zoekt indexer.
  • max_line_match_results - this is an internal field from the gitlab zoekt indexer.
  • max_line_match_results_per_file - this should always take from MultiMatch class, there is a minimum and maximum defined as well as taking chunks_count (if sent) from the graphQL resolver
Edited by 🤖 GitLab Bot 🤖