Skip to content

Commit

Permalink
Merge branch '2733-feature-datastore' of github.com:okfn/ckan into 27…
Browse files Browse the repository at this point in the history
…33-feature-datastore
  • Loading branch information
kindly committed Aug 20, 2012
2 parents 0674318 + b6a4be5 commit 6e376d5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 3 additions & 1 deletion ckan/config/environment.py
Expand Up @@ -16,7 +16,6 @@
import ckan.model as model
import ckan.plugins as p
import ckan.lib.helpers as h
import ckan.lib.search as search
import ckan.lib.app_globals as app_globals

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -161,6 +160,9 @@ def find_controller(self, controller):

# Init SOLR settings and check if the schema is compatible
#from ckan.lib.search import SolrSettings, check_solr_schema_version

# lib.search is imported here as we need the config enabled and parsed
import ckan.lib.search as search
search.SolrSettings.init(config.get('solr_url'),
config.get('solr_user'),
config.get('solr_password'))
Expand Down
3 changes: 2 additions & 1 deletion ckan/lib/search/__init__.py
@@ -1,5 +1,6 @@
import logging
from pylons import config, c
from paste.deploy.converters import asbool

from ckan import model
from ckan.plugins import SingletonPlugin, implements, IDomainObjectModification
Expand Down Expand Up @@ -27,7 +28,7 @@ def text_traceback():
).strip()
return res

SIMPLE_SEARCH = config.get('ckan.simple_search', False)
SIMPLE_SEARCH = asbool(config.get('ckan.simple_search', False))

SUPPORTED_SCHEMA_VERSIONS = ['1.4']

Expand Down
6 changes: 3 additions & 3 deletions ckan/lib/search/sql.py
@@ -1,4 +1,4 @@
from sqlalchemy import or_, and_
from sqlalchemy import or_
from ckan.lib.search.query import SearchQuery
import ckan.model as model

Expand All @@ -17,7 +17,7 @@ def run(self, query):
# no support for faceting atm
self.facets = {}
limit = min(1000, int(query.get('rows', 10)))

q = query.get('q')
ourq = model.Session.query(model.Package.id).filter_by(state='active')

Expand All @@ -34,7 +34,7 @@ def makelike(field):
ourq = ourq.filter(subq)
self.count = ourq.count()
ourq = ourq.limit(limit)
self.results = [r[0] for r in ourq.all()]
self.results = [{'id': r[0]} for r in ourq.all()]

return {'results': self.results, 'count': self.count}

2 changes: 1 addition & 1 deletion ckan/tests/lib/test_simple_search.py
Expand Up @@ -22,7 +22,7 @@ def test_get_all_entity_ids(self):
def test_run_query_basic(self):
res = PackageSearchQuery().run({'q':'annakarenina'})
anna = model.Package.by_name(u'annakarenina')
assert_equal(res, {'results': [anna.id], 'count': 1})
assert_equal(res, {'results': [{'id': anna.id}], 'count': 1})

def test_run_query_home(self):
# This is the query from the CKAN home page
Expand Down
3 changes: 0 additions & 3 deletions doc/datastore.rst
Expand Up @@ -37,9 +37,6 @@ The DataStore in previous lives required a custom setup of ElasticSearch and Ngi
but that is no more, as it can use any relational database management system
(PostgreSQL for example).

To enable datastore features in CKAN
------------------------------------

In your config file ensure that the datastore extension is enabled::

ckan.plugins = datastore
Expand Down

0 comments on commit 6e376d5

Please sign in to comment.