New syntax for pysolr connection
This commit is contained in:
parent
67bd5046df
commit
623fca5f80
|
@ -5,7 +5,6 @@ import logging
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from pylons import config
|
from pylons import config
|
||||||
from paste.deploy.converters import asbool
|
|
||||||
from sqlalchemy import and_, or_
|
from sqlalchemy import and_, or_
|
||||||
|
|
||||||
from ckan.lib.search.index import PackageSearchIndex
|
from ckan.lib.search.index import PackageSearchIndex
|
||||||
|
@ -249,15 +248,26 @@ def harvest_source_index_clear(context, data_dict):
|
||||||
conn = make_connection()
|
conn = make_connection()
|
||||||
query = ''' +%s:"%s" +site_id:"%s" ''' % (
|
query = ''' +%s:"%s" +site_id:"%s" ''' % (
|
||||||
'harvest_source_id', harvest_source_id, config.get('ckan.site_id'))
|
'harvest_source_id', harvest_source_id, config.get('ckan.site_id'))
|
||||||
try:
|
|
||||||
conn.delete_query(query)
|
solr_commit = toolkit.asbool(config.get('ckan.search.solr_commit', 'true'))
|
||||||
if asbool(config.get('ckan.search.solr_commit', 'true')):
|
if toolkit.check_ckan_version(max_version='2.5.99'):
|
||||||
conn.commit()
|
# conn is solrpy
|
||||||
except Exception, e:
|
try:
|
||||||
log.exception(e)
|
conn.delete_query(query)
|
||||||
raise SearchIndexError(e)
|
if solr_commit:
|
||||||
finally:
|
conn.commit()
|
||||||
conn.close()
|
except Exception, e:
|
||||||
|
log.exception(e)
|
||||||
|
raise SearchIndexError(e)
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
else:
|
||||||
|
# conn is pysolr
|
||||||
|
try:
|
||||||
|
conn.delete(q=query, commit=solr_commit)
|
||||||
|
except Exception, e:
|
||||||
|
log.exception(e)
|
||||||
|
raise SearchIndexError(e)
|
||||||
|
|
||||||
return {'id': harvest_source_id}
|
return {'id': harvest_source_id}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue