[ckan-dev] Solr/CKAN - Multi-valued theme - facet

Stéphane Lapointe lapointes at ogsl.ca
Fri Nov 18 13:11:07 UTC 2016


Hi,

if you want to show the facet in the frontend, you need to implement IFacets


class YourPlugin(plugins.SingletonPlugin):
     plugins.implements(plugins.IPackageController, inherit=True)

     plugins.implements(plugins.IFacets)


If I understand what you are trying to do, the link below has a pretty 
good example

https://github.com/ckan/ckanext-eurovoc/blob/master/ckanext/eurovoc/plugin.py

Have a nice day



Le 2016-11-18 à 06:59, Armin Retterath a écrit :
> hi,
>
> i think i've done the first thing ;-) (build the extension and 
> activated in production.ini). now i need a description to show the new 
> facet (of the solr index) in the ckan frontend - i don't find the doc 
> where this is described :-( . do i need to build a further extension?
>
> thanx in advance
>
> armin
>
> 2016-11-17 17:32 GMT+01:00 Stéphane Lapointe <lapointes at ogsl.ca 
> <mailto:lapointes at ogsl.ca>>:
>
>     Hi,
>
>     you can add it in your plugin.py. Be sure to implement
>     IPackageController.
>
>     class YourPlugin(plugins.SingletonPlugin):
>         plugins.implements(plugins.IPackageController, inherit=True)
>
>
>     Good luck
>
>
>     Le 2016-11-17 à 11:29, Armin Retterath a écrit :
>>     hello together,
>>
>>     where i should insert the before_index function, if i don't have
>>     a DataGCCAPackageController class like it is in the canadian
>>     extension??? Which class should be modified instead?
>>
>>     thanx in advance,
>>     armin
>>
>>     2016-11-05 19:51 GMT+01:00 Ian Ward <ian at excess.org
>>     <mailto:ian at excess.org>>:
>>
>>         Hello Stéphane,
>>
>>         One feature missing from Scheming is the ability to adjust
>>         the solr schema to match the extra metadata fields defined.
>>         This is because the solr schema that CKAN uses is static. I
>>         CKAN moves to solr's managed schema in the future so we can
>>         dynamically declare multi-valued fields and have them "just
>>         work" with Scheming fields.
>>
>>         For now you'll need to modify the schema for each of the
>>         multi-valued fields you're saving, e.g.
>>         https://github.com/open-data/ckanext-canada/blob/master/conf/solr/schema.xml#L151
>>         <https://github.com/open-data/ckanext-canada/blob/master/conf/solr/schema.xml#L151>
>>
>>         And you'll need to define a before_index method that passes
>>         the multi-valued field as a list to solr, e.g.
>>         https://github.com/open-data/ckanext-canada/blob/master/ckanext/canada/plugins.py#L370
>>         <https://github.com/open-data/ckanext-canada/blob/master/ckanext/canada/plugins.py#L370>
>>
>>         Hope this helps.
>>
>>         On Thu, Nov 3, 2016 at 7:10 PM, Stéphane Lapointe
>>         <lapointes at ogsl.ca <mailto:lapointes at ogsl.ca>> wrote:
>>
>>             Hi,
>>
>>             To translate our CKAN instance, we're using
>>             ckanext-scheming/ckanext-fluent plugins.
>>
>>             We wanted to add a theming concept to our web site so we
>>             declared a dataset.json schema which contains
>>
>>                     {
>>                       "field_name": "theme",
>>                       "preset": "multiple_checkbox",
>>                       "label": {
>>                         "fr": "Thème",
>>                         "en": "Theme"
>>                       },
>>                       "choices": [
>>                         {
>>                           "value": "biodiversity",
>>                           "label": {
>>                             "fr": "Biodiversité",
>>                             "en": "Biodiversity"
>>                           }
>>                         },
>>                         {
>>                           "value": "marine_conditions",
>>                           "label": {
>>                             "fr": "Conditions maritimes",
>>                             "en": "Marine conditions"
>>                           }
>>                         }
>>                       ]
>>                     },
>>
>>             We can add and save dataset with multiple theme, so we're
>>             assuming this part is set correctly. But, we're having
>>             problem adding a facet theme.
>>
>>
>>             After some debugging, we've found that the Solr's
>>             response is quite strange. Here's what we've added in the
>>             Solr schema.xml:
>>
>>                 <field name="theme" type="text" indexed="true"
>>             stored="true" multiValued="true"/>
>>
>>
>>             When we make a facet query to Solr, this is the response
>>
>>             (...)
>>
>>                 "extras_theme":"[\"*biodiversity*\",
>>             \"*marine_conditions*\"]",
>>
>>             (we observe that this is not normal multiValued like we
>>             see with tags field. It probably should be:
>>             "biodiversity, marine_conditions"... We don't know if
>>             it's plugins' fault. Apparently, the side-effect is that
>>             something went wrong with parsing)
>>
>>             (...)
>>
>>                   "facet_counts":{
>>                     "facet_queries":{},
>>                     "facet_fields":{
>>                       "theme":*[**
>>             **"biodivers",1,**
>>             **            "condit",1,**
>>             **            "marin",1,**
>>             **"marinecondit",1]*},
>>                     "facet_ranges":{},
>>                     "facet_intervals":{},
>>                     "facet_heatmaps":{}}}
>>
>>
>>             Our question: How can we define a parser/analyzer to
>>             obtain a response like that:
>>
>>                   "facet_counts":{
>>                     "facet_queries":{},
>>                     "facet_fields":{
>>                       "theme":*[**
>>             **"biodiversity",1,**
>>             **"marine_condition",1]*},
>>                     "facet_ranges":{},
>>                     "facet_intervals":{},
>>                     "facet_heatmaps":{}}}
>>
>>
>>             Thank you very much.
>>
>>
>>
>>
>>             ------------------------------------------------------------------------
>>             Avast logo <https://www.avast.com/antivirus> 	
>>
>>             This email has been checked for viruses by Avast
>>             antivirus software.
>>             www.avast.com <https://www.avast.com/antivirus>
>>
>>
>>
>>             _______________________________________________
>>             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
>>             <https://lists.okfn.org/mailman/listinfo/ckan-dev>
>>             Unsubscribe:
>>             https://lists.okfn.org/mailman/options/ckan-dev
>>             <https://lists.okfn.org/mailman/options/ckan-dev>
>>
>>
>>
>>         _______________________________________________
>>         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
>>         <https://lists.okfn.org/mailman/listinfo/ckan-dev>
>>         Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>>         <https://lists.okfn.org/mailman/options/ckan-dev>
>>
>>
>>
>>
>>     _______________________________________________
>>     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
>>     <https://lists.okfn.org/mailman/listinfo/ckan-dev>
>>     Unsubscribe:https://lists.okfn.org/mailman/options/ckan-dev
>>     <https://lists.okfn.org/mailman/options/ckan-dev>
>     ------------------------------------------------------------------------
>     Avast logo <https://www.avast.com/antivirus> 	
>
>     This email has been checked for viruses by Avast antivirus
>     software. www.avast.com <https://www.avast.com/antivirus>
>
>     _______________________________________________ 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
>     <https://lists.okfn.org/mailman/listinfo/ckan-dev> Unsubscribe:
>     https://lists.okfn.org/mailman/options/ckan-dev
>     <https://lists.okfn.org/mailman/options/ckan-dev> 
>
> _______________________________________________
> 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


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20161118/29eda57f/attachment-0003.html>


More information about the ckan-dev mailing list