minicomp / wax-facets

The second Wax theme. Good times.
https://minicomp.github.io/wax-facets/
Other
9 stars 8 forks source link

facets filtering only works on some facets #48

Closed jocelynpender closed 1 year ago

jocelynpender commented 1 year ago

I'm using the wax-facets theme to build a very rudimentary data catalogue.

Unfortunately, the gallery.html faceted search only works on one facet: marine_terrestrial_freshwater. For all other facets, nothing is returned by clicking the checkboxes. I am at a loss.. I've experimented with a few things but my lack of in-depth knowledge of Jekyll and Javascript has limited me. Any help is much appreciated!

You can see the behaviour here: https://atlantichabitatmodels.github.io/data/catalogue/

amzoss commented 1 year ago

Hi @jocelynpender. I wonder if one of the problems is that you have some options in your facets with punctuation marks like "?". Especially for Marine Terrestrial Freshwater, where is a value that is a single "?", the "slugify" process that creates the classes used for filtering will just ignore that character entirely, so you won't be able to filter on that at all. Other values like "Open?" will probably just get treated as "Open" by the filter. One reason I think this is a problem is that if you try to check a box while you're watching the JavaScript console, you get an error like:

"Uncaught Error: Syntax error, unrecognized expression: .,.climatic,.freshwater,.marine,.terrestrial at ga.error (jquery-3.2.1.min.js:2:13370)"

At the beginning of the list of classes is a single ".", which is not a valid css class. I think that's the slugified version of "?" causing a JavaScript error.

I'm having trouble completely confirming this. I've been taking a look at your repo using a local copy on my machine, but for some reason when I make changes to the Markdown files in your collection, those changes don't seem to actually be reflected in the site that's being built and served locally. I've been using Jekyll a fair amount lately and that's always worked in the past, so I really am not sure why the build isn't updating the way I'm used to. But from the error and what I remember about the code, I think this is very likely the issue. I'd recommend making sure you're not relying on any of the punctuation marks in your metadata values to differentiate between two options, and you probably can't use anything that is only a punctuation mark.

Otherwise I think the way you're calling the gallery include should be fine!

jocelynpender commented 1 year ago

Hi @amzoss! I really appreciate you looking into this issue! Thanks so much!

I made the changes you suggested (i.e., I removed all "?" from my facets) and this did not solve the issue.

I did pretty extensive testing with my input .csv file to isolate the issue. I think the issue arises when multiple fields have multi-values (e.g., in my instance, marine_terrestrial_freshwater and jurisdiction are both called with * and have multiple values separated by | in the csv data). In the demo site, only one field (tags) has multiple values and these values are separated by pipes. When I call the gallery and have only one field using * to parse multiple values... the gallery works as expected. But when I call more than one field using * (with values separated by pipes to be parsed), things start to go awry. I don't understand the gallery.html file well enough to debug what's going on.

Would you be able to comment on this or take a peek to see if you can recreate this issue?

amzoss commented 1 year ago

Sorry that didn't fix it! Back in March I wasn't able to reproduce the issue you describe on a test Wax site - multiple facet fields had multi-values and it did work as expected - so I don't have a good answer right now. If you could share a version of your site without "?" in the data first, so I don't get that javascript error, that would be helpful for further debugging.

jocelynpender commented 1 year ago

Here is a version of my site without "?": https://github.com/atlantichabitatmodels/data/tree/gallery-testing There is something strange going on with the tags facet - when I include the tags facet in my facet string:

{% include gallery.html facet_by='data_product_type|taxon_group|organization_individual|jurisdiction*|accessibility*|spatial_data_type*|tags*' collection='inputs' num_column=4 %}

none of the muti-value facets seem to work. When I remove tags, things start to function as expected. I've tried changing the tags facet to different values (and tried copying and pasting from your tags data qatar.csv to ensure it wasn't my values causing an issue) and I can't figure out why the faceting seems to choke.

jocelynpender commented 1 year ago

I think I've discovered the root causes of my issues.

  1. The facet name tags and _tags don't seem to work. Swapping this out for keywords leads to good results. I can't figure out why _tags isn't working.. but maybe it does work and my testing site is wacky.
  2. The faceting search breaks down when any facet has no value. This means that for all facets, a value is needed (even when the facet may not apply - a default value like "Not Applicable" might solve this). I'm continuing to test but these are my hunches so far!
jocelynpender commented 1 year ago

I am closing this issue. The two causes I described above were indeed the root causes. Now that I have resolved all missing data, and used the 'keywords' facet name instead of tags, everything is working as expected!

amzoss commented 1 year ago

Thanks so much for sharing your findings here. It's definitely useful to know that there are limitations to the data structure that can be supported.