Back to the room

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 symbols

Loading

Calls (3)
SymbolFileResolved by
_filter_clausesretrieval.pysame file
_keyword_pythonretrieval.pysame file
tsquery_from_termstext.pythrough an import
Called by (1)
SymbolFileResolved by
searchretrieval.pysame file
Inside (1)
SymbolFileResolved by
Retrieverretrieval.pysame 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

Read it on GitHub at this commit