Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works
Code Observatory / method
_keyword
codeintel.retrieval.Retriever._keyword
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 |
|---|---|---|
| _filter_clauses | retrieval.py | same file |
| _keyword_python | retrieval.py | same file |
| tsquery_from_terms | text.py | through an import |
| Symbol | File | Resolved by |
|---|---|---|
| search | retrieval.py | same file |
| Symbol | File | Resolved by |
|---|---|---|
| Retriever | retrieval.py | same file |
codeintel.retrieval.Retriever._keywordbackend/app/codeintel/retrieval.py, lines 321–339Open source
def _keyword(self, terms: list[str], filters: Filters, limit: int) -> list[tuple[str, float]]: if not terms: return [] if not self.is_pg: return self._keyword_python(terms, filters, limit) tsq_text = tsquery_from_terms(terms) if not tsq_text: return [] # Literal SQL so the expression matches the GIN index definition. tsv = literal_column(CHUNK_TSVECTOR_SQL) tsq = func.to_tsquery(literal_column("'simple'"), bindparam("tsq", tsq_text)) score = func.ts_rank_cd(tsv, tsq, 1) stmt = ( select(DocumentChunk.id, score.label("score")) .where(tsv.op("@@")(tsq), *self._filter_clauses(filters)) .order_by(score.desc(), DocumentChunk.id) .limit(limit) ) return [(str(cid), float(sc)) for cid, sc in self.db.execute(stmt)]What the index recorded
- Signature
def _keyword(self, terms: list[str], filters: Filters, limit: int) -> list[tuple[str, float]]:- File
backend/app/codeintel/retrieval.py- Lines
- 321–339
- Parser
- python-ast
- Git blob
884729a39ae0b3d340ad83f75946677dcddf3791- Call sites
- 17 named, 5 resolved, 12 left unlinked
- Outside this subset
- 2 more edges reach code outside the graph shown here
