~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
perf(journals): index Source.score_source; bump schema version (#3568)
LearningCircuitd02c759b97c7
diff --git a/src/local_deep_research/journal_quality/db.py b/src/local_deep_research/journal_quality/db.pyindex 3eafa2b0cf..dbdbc0ff67 100644--- a/src/local_deep_research/journal_quality/db.py+++ b/src/local_deep_research/journal_quality/db.py@@ -66,7 +66,7 @@ _BATCH_SIZE = 5000# Stamped as SQLite `PRAGMA user_version` during build_db; checked on# _ensure_engine. Separate from JOURNAL_DATA_VERSION (downloader.py)# which tracks upstream source-data freshness.-JOURNAL_QUALITY_SCHEMA_VERSION = 1+JOURNAL_QUALITY_SCHEMA_VERSION = 2# Quality tier → score range, used by the dashboard tier filter._TIER_RANGES = {diff --git a/src/local_deep_research/journal_quality/models.py b/src/local_deep_research/journal_quality/models.pyindex eb77b0f9fe..6107e07dab 100644--- a/src/local_deep_research/journal_quality/models.py+++ b/src/local_deep_research/journal_quality/models.py@@ -74,7 +74,13 @@ class Source(JournalQualityBase):Boolean, default=False, index=True)predatory_source: Mapped[str | None] = mapped_column(String)- score_source: Mapped[str] = mapped_column(String, default="openalex")+ # Indexed: the dashboard's /api/journals endpoint filters by+ # score_source (allowlist {openalex, doaj, llm}) and without an+ # index this becomes a full scan of the ~217K-row table. With the+ # index, the filter is a single sub-millisecond lookup.+ score_source: Mapped[str] = mapped_column(+ String, default="openalex", index=True+ )class Institution(JournalQualityBase):diff --git a/tests/journal_quality/test_db.py b/tests/journal_quality/test_db.pyindex e63cf7c091..f6d78b18a8 100644--- a/tests/journal_quality/test_db.py+++ b/tests/journal_quality/test_db.py@@ -272,6 +272,31 @@ class TestBuildReferenceDb:assert count > 200000conn.close()+ def test_built_db_indexes_score_source(self):+ """The dashboard's /api/journals endpoint filters by+ score_source via equality — the column needs an index or+ each filtered page does a full scan of the ~217K-row table.+ Asserted against an in-memory build so the test runs without+ the 350 MB OpenAlex snapshot.+ """+ from sqlalchemy import create_engine, inspect+ from local_deep_research.journal_quality.models import (+ JournalQualityBase,+ )++ engine = create_engine("sqlite:///:memory:")+ JournalQualityBase.metadata.create_all(engine)+ indexed_cols = {+ col+ for idx in inspect(engine).get_indexes("sources")+ for col in idx["column_names"]+ }+ assert "score_source" in indexed_cols, (+ "sources.score_source must be indexed — it's a dashboard "+ "filter predicate; without the index the query does a "+ "full-table scan of ~217K rows."+ )+# ---------------------------------------------------------------------------# _populate_sources unit tests (hijacked + DOAJ-only second pass)