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

Ian Ward ian at excess.org
Fri Nov 18 13:24:27 UTC 2016


We've built our facets on the front end by overriding the facet_list
template to build its labels from the choices in our scheming field.

You should add your facets as Stéphane mentioned, then you can override
your facet_list.html temple to get the choice values and labels from your
schema.  We use the Scheming helpers h.scheming_get_preset or
h.scheming_get_dataset_schema to get the field corresponding to the facet
then h.scheming_field_choices to get the list labels to populate the facets.

Hope this helps.


On Fri, Nov 18, 2016 at 6:59 AM, Armin Retterath <armin.retterath at gmail.com>
wrote:

> 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>:
>
>> 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>:
>>
>>> 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
>>>
>>> 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-d
>>> ata/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>
>>> 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.
>>>>
>>>>
>>>>
>>>>
>>>> ------------------------------
>>>> [image: 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
>>>> https://lists.okfn.org/mailman/listinfo/ckan-dev
>>>> Unsubscribe: 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
>>>
>>>
>>
>>
>> _______________________________________________
>> ckan-dev mailing listckan-dev at lists.okfn.orghttps://lists.okfn.org/mailman/listinfo/ckan-dev
>> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>>
>>
>>
>>
>> ------------------------------
>> [image: 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
>> https://lists.okfn.org/mailman/listinfo/ckan-dev
>> Unsubscribe: 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20161118/9792da2e/attachment-0003.html>


More information about the ckan-dev mailing list