[Koha-bugs] [Bug 36437] Add publication year facet to Elasticsearch
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437 Lucas Gass (lukeg) changed: What|Removed |Added CC||[email protected] Status|Needs Signoff |Patch doesn't apply -- You are receiving this mail because: You are watching all bug changes. ___ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
[Koha-bugs] [Bug 36437] Add publication year facet to Elasticsearch
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437
--- Comment #10 from Michał ---
Until I get around to contributing a correction to re-order this facet in Perl
here, I came up with this JavaScript snippet as a temporary replacement after
being asked by library (works in both OPAC and Intranet), thought I could share
in case someone finds it useful:
// date-of-publication facet in descending order
const dateOfPublicationFacet =
document.querySelector("li#date-of-publication_id:has(#facet-date-of-publication)");
if (dateOfPublicationFacet) {
const numberOfUncollapsed = dateOfPublicationFacet.querySelectorAll("ul
li:not(.collapsible-facet):not(.moretoggle)").length;
[...dateOfPublicationFacet.querySelectorAll("ul li:not(.moretoggle)")]
.map(element => {
element.classList.remove("collapsible-facet");
element.setAttribute("style", "");
return element;
})
.sort((el_a, el_b) => {
const n = e => +e.querySelector(".facet-label").innerText;
const [a, b] = [n(el_a), n(el_b)];
return a > b;
})
.map(element => element.parentNode.insertAdjacentElement("afterbegin",
element))
.reverse()
.slice(numberOfUncollapsed)
.forEach(element => {
element.classList.add("collapsible-facet");
element.setAttribute("style", "display: none;");
});
}
--
You are receiving this mail because:
You are watching all bug changes.
___
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/
[Koha-bugs] [Bug 36437] Add publication year facet to Elasticsearch
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437
--- Comment #9 from David Cook ---
(In reply to Michał from comment #8)
> The only thing that kind of sucks right now is that with
> C4::Context->preference('FacetOrder') eq 'Alphabetical' it's gonna sort the
> years from oldest rather than from newest. I'm not sure if it's worth adding
> some special case there in Search.pm to sort years from newest first instead
> in such case.
I think we did a local version of this, and that's what we ended up doing. I
think it's an important thing to include.
--
I'll make a note to test this patch soon. It would be nice to have!
--
You are receiving this mail because:
You are watching all bug changes.
___
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/
[Koha-bugs] [Bug 36437] Add publication year facet to Elasticsearch
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437 Michał changed: What|Removed |Added CC||[email protected], ||[email protected] Status|ASSIGNED|Needs Signoff Patch complexity|--- |Trivial patch --- Comment #8 from Michał --- Rewritten on top of bug 35138 (one that adds configurable facets). Now it adds year of publication as one of *default* facets. The only thing that kind of sucks right now is that with C4::Context->preference('FacetOrder') eq 'Alphabetical' it's gonna sort the years from oldest rather than from newest. I'm not sure if it's worth adding some special case there in Search.pm to sort years from newest first instead in such case. -- You are receiving this mail because: You are watching all bug changes. ___ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
[Koha-bugs] [Bug 36437] Add publication year facet to Elasticsearch
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437 Michał changed: What|Removed |Added Attachment #163976|0 |1 is obsolete|| --- Comment #7 from Michał --- Comment on attachment 163976 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163976 0001-Bug-36437-Add-publication-year-facet-to-Elasticsearc.patch >From a9ae44f2adff90c234f3b65e439c04c5da4f8dfa Mon Sep 17 00:00:00 2001 >From: MichaÅ Kula <[email protected]> >Date: Wed, 27 Mar 2024 09:00:43 +0100 >Subject: [PATCH] Bug 36437: Add publication year facet to Elasticsearch > >--- > Koha/SearchEngine/Elasticsearch.pm| 2 +- > .../Elasticsearch/QueryBuilder.pm | 17 --- > Koha/SearchEngine/Elasticsearch/Search.pm | 21 ++- > .../searchengine/elasticsearch/mappings.yaml | 21 ++- > .../intranet-tmpl/prog/en/includes/facets.inc | 3 +++ > .../searchengine/elasticsearch/mappings.tt| 3 ++- > .../bootstrap/en/includes/opac-facets.inc | 2 ++ > 7 files changed, 39 insertions(+), 30 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch.pm >b/Koha/SearchEngine/Elasticsearch.pm >index 3f26cbc027..b905f7726f 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -1404,7 +1404,7 @@ sub get_facetable_fields { > > # These should correspond to the ES field names, as opposed to the CCL > # things that zebra uses. >-my @search_field_names = qw( author itype location su-geo title-series >subject ccode holdingbranch homebranch ln ); >+my @search_field_names = qw( author itype location su-geo title-series >subject ccode holdingbranch homebranch ln date-of-publication ); > my @faceted_fields = Koha::SearchFields->search( > { name => { -in => \@search_field_names }, facet_order => { '!=' => > undef } }, { order_by => ['facet_order'] } > )->as_list; >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index 35ab4b7f91..758c8409ec 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -226,14 +226,15 @@ sub build_query { > # things that Koha can use. > my $size = C4::Context->preference('FacetMaxCount'); > $res->{aggregations} = { >-author => { terms => { field => "author__facet" , size => >$size } }, >-subject=> { terms => { field => "subject__facet", size => >$size } }, >-itype => { terms => { field => "itype__facet", size => >$size} }, >-location => { terms => { field => "location__facet", size => >$size } }, >-'su-geo' => { terms => { field => "su-geo__facet", size => >$size} }, >-'title-series' => { terms => { field => "title-series__facet", size >=> $size } }, >-ccode => { terms => { field => "ccode__facet", size => $size >} }, >-ln => { terms => { field => "ln__facet", size => $size } >}, >+author=> { terms => { field => "author__facet" , size >=> $size } }, >+subject => { terms => { field => "subject__facet", size >=> $size } }, >+itype => { terms => { field => "itype__facet", size >=> $size} }, >+location => { terms => { field => "location__facet", >size => $size } }, >+'su-geo' => { terms => { field => "su-geo__facet", size >=> $size} }, >+'title-series'=> { terms => { field => "title-series__facet", >size => $size } }, >+ccode => { terms => { field => "ccode__facet", size >=> $size } }, >+ln=> { terms => { field => "ln__facet", size => >$size } }, >+'date-of-publication' => { terms => { field => >"date-of-publication__facet", size => $size } }, > }; > > my $display_library_facets = > C4::Context->preference('DisplayLibraryFacets'); >diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm >b/Koha/SearchEngine/Elasticsearch/Search.pm >index 933b52f79d..4c1d73a9b1 100644 >--- a/Koha/SearchEngine/Elasticsearch/Search.pm >+++ b/Koha/SearchEngine/Elasticsearch/Search.pm >@@ -444,16 +444,17 @@ sub _convert_facets { > # things that zebra uses. > my %type_to_label; > my %label = ( >-author => 'Authors', >-itype => 'ItemTypes', >-location => 'Location', >-'su-geo' => 'Places', >-'title-series' => 'Series', >-subject=> 'Topics', >-ccode => 'CollectionCodes', >-holdingbranch => 'HoldingLibrary', >-homebranch => 'HomeLibrary', >-ln => 'Language', >+author
[Koha-bugs] [Bug 36437] Add publication year facet to Elasticsearch
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437 --- Comment #6 from Michał --- Created attachment 173716 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=173716&action=edit Bug 36437: add pub year facet to Elasticsearch Notes: - I labeled it as "Year of publication" instead of "Date of publication" since it seems to be more occurate (since the field is a year and that's gonna be better to translate to other langauge) - the third word is not capitalized, since I'm following the naming convention of existing facet labels - facet_order was set to 3, since that should be a pretty common field and useful to display high up to get a quick idea for the range of years the results are from Test plan: 0. Ensure Elasticsearch index is rebuilt (should be on fresh ktd startup?) 1. On intranet go to /cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl 2. Go to second tab there 3. Ensure date-of-publication is in the table, has label in parentheses, has facetable set to Yes 4. Scrolldown to the order of facets table 5. Ensure date-of-publication is there, has label, is third on the list 6. Search for something in intranet, ensure the facet is visible, its value is year, it's clickable and working 7. Search for something in OPAC, as above ensure it works (important to check both OPAC and intranet since facets use different templates to display in both...) -- You are receiving this mail because: You are watching all bug changes. ___ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
[Koha-bugs] [Bug 36437] Add publication year facet to Elasticsearch
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437 Michał changed: What|Removed |Added Status|Needs Signoff |ASSIGNED --- Comment #5 from Michał --- Reverting status to ASSIGNED until I rewrite this on top of bug 35138 in place of the current patch. -- You are receiving this mail because: You are watching all bug changes. ___ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
[Koha-bugs] [Bug 36437] Add publication year facet to Elasticsearch
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437 David Cook changed: What|Removed |Added CC||[email protected] -- You are receiving this mail because: You are watching all bug changes. ___ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
[Koha-bugs] [Bug 36437] Add publication year facet to Elasticsearch
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437 --- Comment #4 from Jonathan Druart --- It could still be added to the default but in my opinion the patch should be written on top of bug 35138. -- You are receiving this mail because: You are watching all bug changes. ___ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
[Koha-bugs] [Bug 36437] Add publication year facet to Elasticsearch
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437 --- Comment #3 from M --- Oh, I didn't. Honestly if they want to make facets configurable in the UI instead of hardcoding them in several places, then that's only for the better. Then that'd obsolete this bug and afterwards we could only argue for including the publication year on by default perhaps... (whether as this bug or by Bug 10734 and marking that one as solved and this one as not applying...) -- You are receiving this mail because: You are watching all bug changes. ___ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
[Koha-bugs] [Bug 36437] Add publication year facet to Elasticsearch
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437 Jonathan Druart changed: What|Removed |Added CC||[email protected] See Also||https://bugs.koha-community ||.org/bugzilla3/show_bug.cgi ||?id=35138 --- Comment #2 from Jonathan Druart --- Hey, did you see bug 35138? -- You are receiving this mail because: You are watching all bug changes. ___ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
[Koha-bugs] [Bug 36437] Add publication year facet to Elasticsearch
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437 M changed: What|Removed |Added Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes. ___ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
[Koha-bugs] [Bug 36437] Add publication year facet to Elasticsearch
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437 --- Comment #1 from M --- Created attachment 163976 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163976&action=edit 0001-Bug-36437-Add-publication-year-facet-to-Elasticsearc.patch -- You are receiving this mail because: You are watching all bug changes. ___ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
