Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works
Code Observatory / function
search_text
codeintel.text.search_text
PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.
PHAROS at 975a38dMIT license
Around this symbol
Search all symbolsLoading
| Symbol | File | Resolved by |
|---|---|---|
| tokenize | text.py | same file |
| Symbol | File | Resolved by |
|---|---|---|
| _build_rows | indexer.py | through an import |
| Symbol | File | Resolved by |
|---|---|---|
| text | text.py | same file |
codeintel.text.search_textbackend/app/codeintel/text.py, lines 152–173Open source
def search_text(sym: Symbol, *, path: str, imports: list[str] | None = None) -> str: """Weighted bag of tokens for PostgreSQL full-text search. Name tokens are repeated three times and path tokens twice so that ``ts_rank_cd`` favours a symbol named after the query over one that merely mentions it. """ name_tokens = tokenize(sym.name, drop_stopwords=False) path_tokens = tokenize(path.replace("/", " ").replace(".", " "), drop_stopwords=False) body: list[str] = [] body += tokenize(sym.signature) body += tokenize(sym.docstring) for call in sym.calls: body += tokenize(call, drop_stopwords=False) for ident in sym.identifiers: body += tokenize(ident, drop_stopwords=False) if sym.kind == "module" and imports: for imp in imports: body += tokenize(imp.replace("/", " ").replace(".", " "), drop_stopwords=False) parts = name_tokens * 3 + path_tokens * 2 + list(dict.fromkeys(body)) text = " ".join(parts) return text[:MAX_SEARCH_TEXT_CHARS]What the index recorded
- Signature
def search_text(sym: Symbol, *, path: str, imports: list[str] | None) -> str:- File
backend/app/codeintel/text.py- Lines
- 152–173
- Parser
- python-ast
- Git blob
74781c9c047d5953611fd7634b2cf29e7661b895- Call sites
- 5 named, 1 resolved, 4 left unlinked
