Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / Source

The two search indexes

HNSW for vectors, GIN for full text. PostgreSQL only; SQLite tests use a Python fallback.

PINNED SOURCE Copied from the repository at this commit. Source, not an execution.

PHAROS at 975a38dMIT license

0002_codeintel upgradebackend/alembic/versions/0002_codeintel.py, lines 110–121Open source
    if op.get_bind().dialect.name == "postgresql":        op.execute(            "CREATE INDEX IF NOT EXISTS idx_chunks_embedding_hnsw "            "ON document_chunks USING hnsw (embedding vector_cosine_ops)"        )        # Must match the expression used by app/codeintel/retrieval.py.        op.execute(            "CREATE INDEX IF NOT EXISTS idx_chunks_search_text_fts "            "ON document_chunks USING gin "            "(to_tsvector('simple', coalesce(search_text, '')))"        )

Where this comes from

Commit
975a38d5d17839c26ee219295a5be6ac66b6d910
File
backend/alembic/versions/0002_codeintel.py
Lines
110–121
Git blob
bd9b903a5dbd18c24b045777658e96213e1b92d3
License
MIT, © 2024–2026 Pharos Contributors. Notice

Read it on GitHub at this commit

Check it yourself

From a clone of the repository, the first command prints the blob above and the second prints these lines.

git rev-parse 975a38d:backend/alembic/versions/0002_codeintel.py
git show 975a38d:backend/alembic/versions/0002_codeintel.py | sed -n '110,121p'