Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted hard-coded search results sort option "by relevance" to configuration individual. #431

Merged
merged 4 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,28 @@ private void addDefaultVitroFacets(VitroRequest vreq, SearchQuery query) {

private void addSortRules(VitroRequest vreq, SearchQuery query, Map<String, SortConfiguration> sortOptions) {
String sortType = getSortType(vreq);
if (sortOptions.isEmpty()) {
return;
}
if (!StringUtils.isBlank(sortType) && sortOptions.containsKey(sortType)) {
SortConfiguration conf = sortOptions.get(sortType);
query.addSortField(conf.getField(vreq.getLocale()), conf.getSortOrder());
String field = conf.getField(vreq.getLocale());
if (!StringUtils.isBlank(field)) {
query.addSortField(field, conf.getSortOrder());
}
conf.setSelected(true);
return;
}
boolean textQueryIsEmpty = StringUtils.isBlank(getQueryText(vreq));
// If text field is empty, apply the first sort option
if (textQueryIsEmpty) {
SortConfiguration conf = sortOptions.entrySet().iterator().next().getValue();
String field = conf.getField(vreq.getLocale());
if (!StringUtils.isBlank(field)) {
query.addSortField(field, conf.getSortOrder());
}
}
// If text field is not empty, sort by relevance (no need to add sort field)
}

private String getSortType(VitroRequest vreq) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,16 @@ public class SearchFiltering {
+ "WHERE {\n"
+ " ?sort rdf:type search:Sort . \n"
+ " ?sort rdfs:label ?sort_label .\n"
+ " ?sort search:sortField ?field .\n"
+ " ?sort search:id ?id .\n"
+ " ?field search:indexField ?searchField .\n"
+ " OPTIONAL {\n"
+ " ?field search:isLanguageSpecific ?f_multilingual .\n"
+ " BIND(?f_multilingual as ?bind_multilingual) .\n"
+ " ?sort search:sortField ?field .\n"
+ " ?field search:indexField ?searchField .\n"
+ " OPTIONAL {\n"
+ " ?field search:isLanguageSpecific ?f_multilingual .\n"
+ " BIND(?f_multilingual as ?bind_multilingual) .\n"
+ " }\n"
+ " }\n"
+ " OPTIONAL {\n"
+ " ?sort search:id ?id .\n"
+ " }\n"
+ " OPTIONAL {\n"
+ " ?sort search:isAscending ?f_ord .\n"
Expand Down Expand Up @@ -340,12 +344,13 @@ public static Map<String, SortConfiguration> getSortConfigurations(VitroRequest
ResultSet results = qexec.execSelect();
while (results.hasNext()) {
QuerySolution solution = results.nextSolution();
if (solution.get("label") == null || solution.get("id") == null
|| solution.get("searchField") == null) {
RDFNode searchFieldNode = solution.get("searchField");
RDFNode idNode = solution.get("id");
if (solution.get("label") == null) {
continue;
}
String field = solution.get("searchField").toString();
String id = solution.get("id").toString();
String field = searchFieldNode == null ? "" : searchFieldNode.toString();
String id = idNode == null ? "" : idNode.toString();
String label = solution.get("label").toString();

SortConfiguration config = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
vitro-search:order 30 ;
vitro-search:id "titleasc" .

:sort_by_relevance a vitro-search:Sort ;
vitro-search:id "relevance" .

:field_label_sort
a vitro-search:SearchField ;
vitro-search:isLanguageSpecific true ;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@prefix : <https://vivoweb.org/ontology/vitro-search-individual/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:filter_group_search_filters rdfs:label "Suchfilter"@de-DE .
:filter_type rdfs:label "Typ"@de-DE .
:filter_category rdfs:label "Kategorie"@de-DE .
:sort_title_desc rdfs:label "Titel Z-A"@de-DE .
:sort_title_asc rdfs:label "Titel A-Z"@de-DE .
:sort_by_relevance rdfs:label "Relevanz"@de-DE .
:field_label_sort rdfs:label "Etikettensortierfeld"@de-DE .
:field_category rdfs:label "Klassengruppe"@de-DE .
:field_type rdfs:label "Typ"@de-DE .
:filter_querytext rdfs:label "Text"@de-DE .
:field_querytext rdfs:label "Standardfeld"@de-DE .
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix uil-data: <http://vivoweb.org/ontology/vitro/ui-label/individual#> .
@prefix uil: <http://vivoweb.org/ontology/vitro/ui-label/vocabulary#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

uil-data:search_results_sort_by.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "Sortieren nach {0}"@de-DE ;
uil:hasApp "Vitro" ;
uil:hasKey "search_results_sort_by" ;
uil:hasPackage "Vitro-languages" .

uil-data:search_results_per_page.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "{0} Ergebnisse pro Seite"@de-DE ;
uil:hasApp "Vitro" ;
uil:hasKey "search_results_per_page" ;
uil:hasPackage "Vitro-languages" .

uil-data:search_field_placeholder.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "Suchbegriff eingeben"@de-DE ;
uil:hasApp "Vitro" ;
uil:hasKey "search_field_placeholder" ;
uil:hasPackage "Vitro-languages" .

uil-data:results_found.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "{0} Ergebnisse gefunden"@de-DE ;
uil:hasApp "Vitro" ;
uil:hasKey "results_found" ;
uil:hasPackage "Vitro-languages" .

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@prefix : <https://vivoweb.org/ontology/vitro-search-individual/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:filter_group_search_filters rdfs:label "Filters"@en-CA .
:filter_type rdfs:label "Type"@en-CA .
:filter_category rdfs:label "Category"@en-CA .
:sort_title_desc rdfs:label "Title Z-A"@en-CA .
:sort_title_asc rdfs:label "Title A-Z"@en-CA .
:sort_by_relevance rdfs:label "Relevance"@en-CA .
:field_label_sort rdfs:label "Label sort field"@en-CA .
:field_category rdfs:label "ClassGroup"@en-CA .
:field_type rdfs:label "Type"@en-CA .
:filter_querytext rdfs:label "Text"@en-CA .
:field_querytext rdfs:label "Default field"@en-CA .
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix uil-data: <http://vivoweb.org/ontology/vitro/ui-label/individual#> .
@prefix uil: <http://vivoweb.org/ontology/vitro/ui-label/vocabulary#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

uil-data:search_results_sort_by.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "Sort by {0}"@en-CA ;
uil:hasApp "Vitro" ;
uil:hasKey "search_results_sort_by" ;
uil:hasPackage "Vitro-languages" .

uil-data:search_results_per_page.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "{0} results per page"@en-CA ;
uil:hasApp "Vitro" ;
uil:hasKey "search_results_per_page" ;
uil:hasPackage "Vitro-languages" .

uil-data:search_field_placeholder.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "Enter search term"@en-CA ;
uil:hasApp "Vitro" ;
uil:hasKey "search_field_placeholder" ;
uil:hasPackage "Vitro-languages" .

uil-data:results_found.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "{0} results found"@en-CA ;
uil:hasApp "Vitro" ;
uil:hasKey "results_found" ;
uil:hasPackage "Vitro-languages" .

Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@prefix : <https://vivoweb.org/ontology/vitro-search-individual/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:filter_group_search_filters rdfs:label "Search filters"@en-US .
:filter_group_search_filters rdfs:label "Filters"@en-US .
:filter_type rdfs:label "Type"@en-US .
:filter_category rdfs:label "Category"@en-US .
:sort_title_desc rdfs:label "Title Z-A"@en-US .
:sort_title_asc rdfs:label "Title A-Z"@en-US .
:sort_by_relevance rdfs:label "Relevance"@en-US .
:field_label_sort rdfs:label "Label sort field"@en-US .
:field_category rdfs:label "ClassGroup"@en-US .
:field_type rdfs:label "Type"@en-US .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,35 @@
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

uil-data:search_results_relevance.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "Relevance"@en-US ;
uil:hasApp "Vitro" ;
uil:hasKey "search_results_relevance" ;
uil:hasPackage "Vitro-languages" .

uil-data:search_results_sort_by.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "Sort by"@en-US ;
uil:hasApp "Vitro" ;
uil:hasKey "search_results_sort_by" ;
uil:hasPackage "Vitro-languages" .
rdfs:label "Sort by {0}"@en-US ;
uil:hasApp "Vitro" ;
uil:hasKey "search_results_sort_by" ;
uil:hasPackage "Vitro-languages" .

uil-data:search_results_per_page.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "Results per page"@en-US ;
uil:hasApp "Vitro" ;
uil:hasKey "search_results_per_page" ;
uil:hasPackage "Vitro-languages" .
rdfs:label "{0} Results per page"@en-US ;
uil:hasApp "Vitro" ;
uil:hasKey "search_results_per_page" ;
uil:hasPackage "Vitro-languages" .

uil-data:search_field_placeholder.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "Enter search term"@en-US ;
uil:hasApp "Vitro" ;
uil:hasKey "search_field_placeholder" ;
uil:hasPackage "Vitro-languages" .
uil:hasApp "Vitro" ;
uil:hasKey "search_field_placeholder" ;
uil:hasPackage "Vitro-languages" .

uil-data:results_found.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "results found"@en-US ;
uil:hasApp "Vitro" ;
uil:hasKey "results_found" ;
uil:hasPackage "Vitro-languages" .
rdfs:label "{0} results found"@en-US ;
uil:hasApp "Vitro" ;
uil:hasKey "results_found" ;
uil:hasPackage "Vitro-languages" .

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@prefix : <https://vivoweb.org/ontology/vitro-search-individual/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:filter_group_search_filters rdfs:label "Filtros de búsqueda"@es .
:filter_type rdfs:label "Tipo"@es .
:filter_category rdfs:label "Categoría"@es .
:sort_title_desc rdfs:label "Título Z-A"@es .
:sort_title_asc rdfs:label "Título A-Z"@es .
:sort_by_relevance rdfs:label "Relevancia"@es .
:field_label_sort rdfs:label "Campo de clasificación de etiquetas"@es .
:field_category rdfs:label "Grupo de clase"@es .
:field_type rdfs:label "Tipo"@es .
:filter_querytext rdfs:label "Texto"@es .
:field_querytext rdfs:label "Campo predeterminado"@es .
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix uil-data: <http://vivoweb.org/ontology/vitro/ui-label/individual#> .
@prefix uil: <http://vivoweb.org/ontology/vitro/ui-label/vocabulary#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

uil-data:search_results_sort_by.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "Ordenar por {0}"@es ;
uil:hasApp "Vitro" ;
uil:hasKey "search_results_sort_by" ;
uil:hasPackage "Vitro-languages" .

uil-data:search_results_per_page.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "{0} resultados por página"@es ;
uil:hasApp "Vitro" ;
uil:hasKey "search_results_per_page" ;
uil:hasPackage "Vitro-languages" .

uil-data:search_field_placeholder.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "Introduzca el término de búsqueda"@es ;
uil:hasApp "Vitro" ;
uil:hasKey "search_field_placeholder" ;
uil:hasPackage "Vitro-languages" .

uil-data:results_found.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "{0} resultados encontrados"@es ;
uil:hasApp "Vitro" ;
uil:hasKey "results_found" ;
uil:hasPackage "Vitro-languages" .

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@prefix : <https://vivoweb.org/ontology/vitro-search-individual/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:filter_group_search_filters rdfs:label "Filtres"@fr-CA .
:filter_type rdfs:label "Taper"@fr-CA .
:filter_category rdfs:label "Catégorie"@fr-CA .
:sort_title_desc rdfs:label "Titre Z-A"@fr-CA .
:sort_title_asc rdfs:label "Titre A-Z"@fr-CA .
:sort_by_relevance rdfs:label "Pertinence"@fr-CA .
:field_label_sort rdfs:label "Champ de tri des étiquettes"@fr-CA .
:field_category rdfs:label "Groupe de classe"@fr-CA .
:field_type rdfs:label "Taper"@fr-CA .
:filter_querytext rdfs:label "Texte"@fr-CA .
:field_querytext rdfs:label "Champ par défaut"@fr-CA .
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix uil-data: <http://vivoweb.org/ontology/vitro/ui-label/individual#> .
@prefix uil: <http://vivoweb.org/ontology/vitro/ui-label/vocabulary#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

uil-data:search_results_sort_by.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "Trier par {0}"@fr-CA ;
uil:hasApp "Vitro" ;
uil:hasKey "search_results_sort_by" ;
uil:hasPackage "Vitro-languages" .

uil-data:search_results_per_page.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "{0} résultats par page"@fr-CA ;
uil:hasApp "Vitro" ;
uil:hasKey "search_results_per_page" ;
uil:hasPackage "Vitro-languages" .

uil-data:search_field_placeholder.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "Entrez le terme de recherche"@fr-CA ;
uil:hasApp "Vitro" ;
uil:hasKey "search_field_placeholder" ;
uil:hasPackage "Vitro-languages" .

uil-data:results_found.Vitro
rdf:type owl:NamedIndividual ;
rdf:type uil:PropertyKey ;
rdfs:label "{0} résultats trouvés"@fr-CA ;
uil:hasApp "Vitro" ;
uil:hasKey "results_found" ;
uil:hasPackage "Vitro-languages" .

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@prefix : <https://vivoweb.org/ontology/vitro-search-individual/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:filter_group_search_filters rdfs:label "Filtros"@pt-BR .
:filter_type rdfs:label "Tipo"@pt-BR .
:filter_category rdfs:label "Categoria"@pt-BR .
:sort_title_desc rdfs:label "Título Z-A"@pt-BR .
:sort_title_asc rdfs:label "Título A-Z"@pt-BR .
:sort_by_relevance rdfs:label "Relevância"@pt-BR .
:field_label_sort rdfs:label "Campo de ordenação por rótulo"@pt-BR .
:field_category rdfs:label "Grupo de Classe"@pt-BR .
:field_type rdfs:label "Tipo"@pt-BR .
:filter_querytext rdfs:label "Texto"@pt-BR .
:field_querytext rdfs:label "Campo padrão"@pt-BR .
Loading
Loading