source: main/trunk/greenstone3/web/interfaces/default/js/facet-scripts.js@ 32110

Last change on this file since 32110 was 32110, checked in by ak19, 6 years ago

Forgot to commit bugfix. The bug was that when searching a solr collection, if you switch on a facet containing an apostrophe (try searching solr-demo for query term farm and then selecting the facet with apostrophe), there are 0 search results displayed for that facet despite the facet listing a positive number of matching docs for it. 1. Greenstone3SearchHandler.java and facet-scripts.js contain the fix. 2. GS2SolrSearch.java and SolrQueryWrapper.java just contain further debug statements, some commented out.

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1function performRefinedSearch()
2{
3 var allCheckBoxes = $("#facetSelector input");
4 var counts = new Array();
5 for(var i = 0; i < allCheckBoxes.length; i++)
6 {
7 var current = $(allCheckBoxes[i]);
8 if(current.prop("checked"))
9 {
10 counts.push(current.parent().parent().attr("indexName") + ":(\"" + current.siblings("span").first().html() + "\")");
11 }
12 }
13
14 var searchString = "";
15 for(var key in gs.cgiParams)
16 {
17 if (gs.cgiParams.hasOwnProperty(key))
18 {
19 searchString += key.replace(/_/g, ".") + "=" + gs.cgiParams[key] + "&";
20 }
21 }
22
23 var countsString = "s1.facetQueries=&";
24 if(counts.length > 0)
25 {
26 countsString = "s1.facetQueries=[";
27 var countsStringBuffer = "";
28 for(var i = 0; i < counts.length; i++)
29 {
30 // escape any apostrophes in facet query terms
31 // (ext/solr's Greenstone3SearchHandler does the other half of handling them)
32 countsStringBuffer += "\"" + encodeURI(counts[i]).replace(/'/g, "%2527") + "\"";
33 if(i < counts.length - 1)
34 {
35 countsStringBuffer += ", ";
36 }
37 }
38
39 countsString += encodeURI(countsStringBuffer) + "]&";
40 }
41
42 console.log("STRING IS " + countsString)
43
44 $.ajax(gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/search/" + gs.cgiParams.s + "?" + searchString + countsString + "excerptid=resultsArea")
45 .done(function(response)
46 {
47 $("#resultsArea").html("");
48 $("#resultsArea").html(response.substring(response.indexOf(">") + 1, response.lastIndexOf("<")));
49 });
50}
51
52function expandFacetList(indexName, countSize)
53{
54 var tables = $(".facetTable");
55
56 for(var i = 0; i < tables.length; i++)
57 {
58 var current = $(tables[i]);
59 if(current.attr("indexName") == indexName)
60 {
61 var items = current.children("li");
62
63 for(var j = 0; j < items.length; j++)
64 {
65 $(items[j]).css("display", "block");
66 }
67
68 break;
69 }
70 }
71
72 // the above code has made both see more and see less links display=block, so we need to hide
73 // see more
74 var morelink = $(".expandFacetList" + indexName);
75 morelink.css("display", "none");
76
77}
78
79function collapseFacetList(indexName, countSize)
80{
81 var tables = $(".facetTable");
82
83 for(var i = 0; i < tables.length; i++)
84 {
85 var current = $(tables[i]);
86 if(current.attr("indexName") == indexName)
87 {
88 var items = current.children("li");
89
90 for(var j = 0; j < items.length; j++)
91 {
92 if(j > countSize)
93 {
94 $(items[j]).css("display", "none");
95 }
96 }
97
98 break;
99 }
100 }
101
102 // the above code has hidden both the see more and see less links.
103 // display the see more one
104 var morelink = $(".expandFacetList" + indexName);
105 morelink.css("display", "block");
106
107}
108
Note: See TracBrowser for help on using the repository browser.