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

Alex (Maxious) Sadleir maxious at gmail.com
Fri Jan 9 05:21:15 UTC 2015


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> 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
>
>
>
>
>
>
>
> [image: cid:image001.gif at 01CC55BF.85E7FEB0]
>
> Qifeng Bai
> Software Engineer
> CSIRO Land and Water
> Black Mountain, Canberra
>
> Ph: +61-2-62465704
> Web: www.clw.csiro.au
>
>
>
>
>
> _______________________________________________
> ckan-dev mailing list
> 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/20150109/836bcc9d/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 2094 bytes
Desc: not available
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150109/836bcc9d/attachment-0003.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: org_search.patch
Type: text/x-patch
Size: 1013 bytes
Desc: not available
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150109/836bcc9d/attachment-0003.bin>


More information about the ckan-dev mailing list