From 5ae386783b81f4e2019f1d9a0d4f534c22c01a89 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 3 Aug 2021 18:35:42 -0700 Subject: ES: add 'preference' query param; default to '_local' in prod --- fatcat_scholar/search.py | 3 +++ settings.toml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py index 121cb69..dccaf07 100644 --- a/fatcat_scholar/search.py +++ b/fatcat_scholar/search.py @@ -377,6 +377,9 @@ def do_fulltext_search( search = search.params(track_total_hits=True) search = search[offset : (offset + limit)] + if settings.ELASTICSEARCH_QUERY_PREFERENCE: + search = search.params(preference=settings.ELASTICSEARCH_QUERY_PREFERENCE) + query_start = datetime.datetime.now() try: resp = search.execute() diff --git a/settings.toml b/settings.toml index 76488b0..07ba1bd 100644 --- a/settings.toml +++ b/settings.toml @@ -5,6 +5,7 @@ SCHOLAR_ISSUEDB_PATH = "data/issue_db.sqlite" I18N_LANG_DEFAULT = "en" ELASTICSEARCH_QUERY_BASE = "http://localhost:9200" ELASTICSEARCH_QUERY_FULLTEXT_INDEX = "scholar_fulltext" +ELASTICSEARCH_QUERY_PREFERENCE = "" ELASTICSEARCH_WRITE_BASE = "http://localhost:9200" ELASTICSEARCH_WRITE_FULLTEXT_INDEX = "scholar_fulltext_v01" ELASTICSEARCH_PUBLIC_URL = "http://localhost:9292" @@ -65,6 +66,7 @@ SCHOLAR_ENV = "prod" ONION_DOMAIN = "scholar.archivev3qli37bju4rlh27glh24lljyezwxf4pokmrdbpefjlcrp5id.onion" ELASTICSEARCH_QUERY_BASE = "http://localhost:9292" ELASTICSEARCH_QUERY_FULLTEXT_INDEX = "scholar_fulltext" +ELASTICSEARCH_QUERY_PREFERENCE = "_local" ELASTICSEARCH_WRITE_BASE = "http://localhost:9200" ELASTICSEARCH_WRITE_FULLTEXT_INDEX = "scholar_fulltext_v01_20210128" ELASTICSEARCH_PUBLIC_URL = "https://search.fatcat.wiki" -- cgit v1.2.3