[ckan-dev] Can search function work on 'organisation' and 'group' level

Qifeng.Bai at csiro.au Qifeng.Bai at csiro.au
Sun Jan 11 23:35:48 UTC 2015


Thanks for your answer. However I got an error after I added your codes into query.py

if not q or q == '""' or q == "''":
            query['q'] = "*:*"
        elif ':' not in q:
            query['q'] = query['q'] + " OR organization:*"+query['q']+"*" + " OR groups:*"+query['q']+"*"

Error: "org.apache.lucene.queryParser.ParseException: Cannot parse \'test OR organization:*test* OR groups:*test*\': \'*\' or \'?\' not allowed as first character in WildcardQuery"',)

I understand Lucene doesn't allow you to start WildcardQueries with an asterisk by default, because those are incredibly expensive queries and will be very, very, very slow on large indexes. How do you overcome this problem?

Cheers





From: ckan-dev [mailto:ckan-dev-bounces at lists.okfn.org] On Behalf Of Alex (Maxious) Sadleir
Sent: Friday, 9 January 2015 4:21 PM
To: CKAN Development Discussions
Subject: Re: [ckan-dev] Can search function work on 'organisation' and 'group' level

Yes, if you patch the solr config (I also patch the search controller but that might be overkill).

diff --git a/ckan/config/solr/schema.xml b/ckan/config/solr/schema.xml
index 26b8f0d..0812100 100644
--- a/ckan/config/solr/schema.xml
+++ b/ckan/config/solr/schema.xml
@@ -161,5 +161,7 @@
 <copyField source="res_description" dest="text"/>
 <copyField source="maintainer" dest="text"/>
 <copyField source="author" dest="text"/>
+<copyField source="organization" dest="text"/>
+<copyField source="groups" dest="text"/>

 </schema>
diff --git a/ckan/lib/search/query.py b/ckan/lib/search/query.py
index 881ddc9..ecee687 100644
--- a/ckan/lib/search/query.py
+++ b/ckan/lib/search/query.py
@@ -309,7 +309,8 @@ class PackageSearchQuery(SearchQuery):
         q = query.get('q')
         if not q or q == '""' or q == "''":
             query['q'] = "*:*"
-
+        elif ':' not in q:
+            query['q'] = query['q'] + " OR organization:*"+query['q']+"*" + " OR groups:*"+query['q']+"*"
         # number of results
         rows_to_return = min(1000, int(query.get('rows', 10)))
         if rows_to_return > 0:


On Fri, Jan 9, 2015 at 3:48 PM, <Qifeng.Bai at csiro.au<mailto:Qifeng.Bai at csiro.au>> wrote:
Happy New Year

Here is a question concerning the search function of the database.  As far as I can ascertain the search function works on identifying key words from the “dataset” level of the database.  Is it possible that the search function can be expanded to consider the “organisation” and “group” levels as well.

Cheers





[cid:image001.gif at 01CC55BF.85E7FEB0]

Qifeng Bai
Software Engineer
CSIRO Land and Water
Black Mountain, Canberra

Ph: +61-2-62465704<tel:%2B61-2-62465704>
Web: www.clw.csiro.au<http://www.clw.csiro.au>




_______________________________________________
ckan-dev mailing list
ckan-dev at lists.okfn.org<mailto:ckan-dev at lists.okfn.org>
https://lists.okfn.org/mailman/listinfo/ckan-dev
Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150111/c97439b1/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 2094 bytes
Desc: image001.gif
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150111/c97439b1/attachment-0003.gif>


More information about the ckan-dev mailing list