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

Ian Ward ian at excess.org
Sat Nov 5 18:51:16 UTC 2016


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-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> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20161105/46bba8e8/attachment-0003.html>


More information about the ckan-dev mailing list