Skip to content

Commit 5710ec8

Browse files
authored
Merge pull request #20762 from cockroachdb/fix-session-variable-search
Fix session variable search discoverability in documentation
2 parents d0fdc7e + 3b87207 commit 5710ec8

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/current/algolia_index_intelligent_bloat_removal.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,30 @@ def get_git_last_modified(file_path: pathlib.Path) -> str:
714714
GIT_DATE_CACHE[cache_key] = date
715715
return date
716716

717+
def enhance_session_variable_content(content: str, element, context: Dict[str, str]) -> str:
718+
"""Add session variable name to description records where missing for better discoverability."""
719+
# Only for session-variables.html page
720+
if 'session-variables.html' not in context.get('url', ''):
721+
return content
722+
723+
# Check if this is a description cell adjacent to a variable name cell
724+
if element.name == 'td':
725+
prev_sibling = element.find_previous_sibling('td')
726+
if prev_sibling:
727+
prev_text = extract_text_with_spaces(prev_sibling).strip()
728+
729+
# If previous cell contains a session variable name pattern
730+
if (re.match(r'^\w+(_\w+)+$', prev_text) and
731+
'_' in prev_text and
732+
len(prev_text) > 5 and
733+
len(prev_text) < 50 and
734+
prev_text not in content):
735+
736+
# Prepend variable name to description for discoverability
737+
return f"{prev_text}: {content}"
738+
739+
return content
740+
717741
def extract_records_from_html(html_path: pathlib.Path, versions: Dict[str, str] = None) -> List[Dict[str, Any]]:
718742
"""Proven extraction + intelligent bloat removal."""
719743
if should_exclude_file(str(html_path), versions):
@@ -780,6 +804,9 @@ def extract_records_from_html(html_path: pathlib.Path, versions: Dict[str, str]
780804
continue
781805

782806
text = extract_text_with_spaces(element)
807+
808+
# Enhance session variable content for better discoverability
809+
text = enhance_session_variable_content(text, element, filter_context)
783810

784811
# INTELLIGENT BLOAT REMOVAL - context-aware filtering
785812
if bloat_filter.is_bloat_content(text, filter_context):

0 commit comments

Comments
 (0)