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
NumContextLinesin zoekt). - the
MultiMatchclass is hardcoded to show 2 lines before & 2 lines after maximum. -
Search::Zoekt::Client: This set withCONTEXT_LINES_COUNT. - default is
20but should use the default fromMultiMatchconstant:NEW_CHUNK_THRESHOLDinstead of20
- corresponds to "this many number of context lines will be added before and after each matched line." (see
-
max_file_match_window- this is "Maximum number of matches" (see
TotalMatchCountin zoekt) -
Search::Zoekt::SearchResults: This is set withSearch::Zoekt::SearchResults::ZOEKT_COUNT_LIMIT - default should be
Search::Zoekt::SearchResults::ZOEKT_COUNT_LIMITinstead of1000
- this is "Maximum number of matches" (see
-
max_file_match_results- this is an internal field from the gitlab zoekt indexer.-
Search::Zoekt::SearchResults: This is set withSearch::Zoekt::SearchResults::ZOEKT_COUNT_LIMIT- default should be
Search::Zoekt::SearchResults::ZOEKT_COUNT_LIMITinstead of5
- default should be
-
-
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 fromMultiMatchclass, there is a minimum and maximum defined as well as takingchunks_count(if sent) from the graphQL resolver
Edited by 🤖 GitLab Bot 🤖