Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Example:
"config": {
"search_backend": "solr",
"solr_service_url": "http://localhost:8983/solr/gdi/select",
"solr_service_auth": {
"username": "solr",
"password": "SolrRocks"
},
"search_result_sort": "score desc, sort asc",
"word_split_re": "[\\s,.:;\"]+",
"search_result_limit": 50,
Expand Down
14 changes: 14 additions & 0 deletions schemas/qwc-search-service.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@
"description": "SOLR service URL",
"type": "string"
},
"solr_service_auth": {
"description": "SOLR service basic authentication. Default: None",
"type": "object",
"properties": {
"username": {
"description": "Username for SOLR service authentication",
"type": "string"
},
"password": {
"description": "Password for SOLR service authentication",
"type": "string"
}
}
},
"search_result_sort": {
"description": "Search result ordering for solr search results. Default: search_result_sort",
"type": "string"
Expand Down
8 changes: 8 additions & 0 deletions src/solr_search_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ def __init__(self, tenant, logger):

self.solr_service_url = config.get(
'solr_service_url', 'http://localhost:8983/solr/gdi/select')

self.solr_service_auth = config.get('solr_service_auth', None)

if self.solr_service_auth:
self.solr_service_auth = (self.solr_service_auth.get('username'),
self.solr_service_auth.get('password'))

self.word_split_re = re.compile(
config.get('word_split_re', r'[\s,.:;"]+')
)
Expand Down Expand Up @@ -85,6 +92,7 @@ def query(self, tokens, filterword, filter_ids, limit, solr_facets):
self.solr_service_url,
params="omitHeader=true&facet=true&facet.field=facet&sort=" +
self.search_result_sort + "&rows={}&{}&{}".format(limit, q, fq),
auth=self.solr_service_auth,
timeout=10)
self.logger.debug("Sending Solr query %s" % response.url)
self.logger.info("Search words: %s", ','.join(tokens))
Expand Down