-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_search.py
50 lines (41 loc) · 1.31 KB
/
config_search.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import inspect
import os
import sys
# Full-text search config parameters
SOLR_URL = {
"prod": "http://macc-ht-solr-lss-1.umdl.umich.edu:8081/solr/core-1x/query",
"dev": "http://solr-lss-dev:8983/solr/core-x/query"
}
FULL_TEXT_SEARCH_SHARDS_X = ','.join([f"http://solr-sdr-search-{i}:8081/solr/core-{i}x" for i in range(1, 12)])
FULL_TEXT_SEARCH_SHARDS_Y = ','.join([f"http://solr-sdr-search-{i}:8081/solr/core-{i}y" for i in range(1, 12)])
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
sys.path.insert(0, current_dir)
QUERY_PARAMETER_CONFIG_FILE = "/".join(
[current_dir, "config_files/full_text_search/config_query.yaml"]
)
FACET_FILTERS_CONFIG_FILE = "/".join(
[current_dir, "config_files/full_text_search/config_facet_filters.yaml"]
)
DEFAULT_SOLR_PARAMS = {
"rows": 500,
"sort": "id asc",
"fl": ",".join(["title", "author", "id"]),
"wt": "json"
}
def default_solr_params(env: str = "prod"):
"""
Return the default solr parameters
:param env:
:return:
"""
if env == "prod":
add_shards(DEFAULT_SOLR_PARAMS)
return DEFAULT_SOLR_PARAMS
def add_shards(params: dict):
"""
Add shards to the params
:param params:
:return:
"""
params.update({"shards": FULL_TEXT_SEARCH_SHARDS_X})
return params