From 4e2ab892be6556bd904cf4082727e6c9252c8da4 Mon Sep 17 00:00:00 2001 From: Mikko Koho Date: Mon, 21 Jul 2014 11:46:17 +0300 Subject: [PATCH] Add quotes to package ID and name in Solr queries to prevent Solr errors with custom dataset identifiers. --- ckan/lib/search/query.py | 2 +- ckan/logic/action/update.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ckan/lib/search/query.py b/ckan/lib/search/query.py index 881ddc96938..9d0cb70f2fc 100644 --- a/ckan/lib/search/query.py +++ b/ckan/lib/search/query.py @@ -264,7 +264,7 @@ def get_all_entity_ids(self, max_results=1000): def get_index(self,reference): query = { 'rows': 1, - 'q': 'name:%s OR id:%s' % (reference,reference), + 'q': 'name:"%s" OR id:"%s"' % (reference,reference), 'wt': 'json', 'fq': 'site_id:"%s"' % config.get('ckan.site_id')} diff --git a/ckan/logic/action/update.py b/ckan/logic/action/update.py index 3cbd2abbe8d..770869e44e9 100644 --- a/ckan/logic/action/update.py +++ b/ckan/logic/action/update.py @@ -1189,7 +1189,7 @@ def process_solr(q): count = 0 q = [] for id in datasets: - q.append('id:%s' % (id)) + q.append('id:"%s"' % (id)) count += 1 if count % BATCH_SIZE == 0: process_solr(' OR '.join(q))