Item12959: Make it possible to filter webs with subwebs

pencil
Priority: Enhancement
Current State: No Action Required
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: SolrPlugin
Branches:
Reported By: StephanOsthold
Waiting For:
Last Change By: StephanOsthold
I wish to limit SolrSearch to a web, for example with:
%TMPL:DEF{"solr::defaultweb"}%MyWeb%TMPL:END%

However I run into trouble when also including all subwebs like this:
%TMPL:DEF{"solr::defaultweb"}%MyWeb*%TMPL:END%
because the * will crash the webs facet.

I'd like to suggest this change:
Index: SolrPlugin/pub/System/SolrPlugin/ajax-solr.uncompressed.js
===================================================================
--- SolrPlugin/pub/System/SolrPlugin/ajax-solr.uncompressed.js  (revision 17806)
+++ SolrPlugin/pub/System/SolrPlugin/ajax-solr.uncompressed.js  (working copy)
@@ -1695,8 +1695,11 @@
     if (params) {
       for (i in params) {
         param = params[i];
-        q = (this.union ? new RegExp('^-?' + this.field + ':\\((.*)\\)')
-            : new RegExp('^-?' + this.field + ':(.*)')).exec(param.val())[1];
+        var fieldQuoted = this.field.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
+        var match = (this.union ? new RegExp('^-?' + fieldQuoted + ':\\((.*)\\)')
+            : new RegExp('^-?' + fieldQuoted + ':(.*)')).exec(param.val());
+        if (!match) continue;
+        q = match[1];
         if (this.union) {
           values = AjaxSolr.parseStringList(q).slice();
         } else {

-- StephanOsthold - 09 Jul 2014

Please don't patch against ajax-solr.uncompressed.js as it is auto-generated by the Makefile. Which file that ajax-solr.uncompressed.js is derived from do you really want to patch?

What do you mean by "crash"? Is it a javascript error, the solr server barfing, or simply not working as expected?

Could you please explain what your js patch is doing? I don't get the code change.

In SolrSearchBaseTemplate the defaultweb template is used to filter using a web:... filter. That's probably not what you're intending to do. A better and more flexible way to configure the filter is to use the SOLR_EXTRAFILTER preference setting and then use a web_search:FooBar* expression to limit the scope of the search.

-- MichaelDaum - 09 Jul 2014

Sorry for the late reply, not much time lately.

By "crash" I mean that the javascript (ajax-solr.js) will cause an error and the page will not load (remains blocked). The problem is that "MyWeb*" is not among the selectable facets, so the RegExp does not match and (RegExp(...).exec(...))[1] is an error.

web_search:FooBar* also matches "AnythingFooBar" which is not what I want (WordDelimiterFilter).

As a workaround I am going to copy web into another field, so no action required.

-- StephanOsthold - 29 Jul 2014
 

ItemTemplate edit

Summary Make it possible to filter webs with subwebs
ReportedBy StephanOsthold
Codebase trunk
SVN Range
AppliesTo Extension
Component SolrPlugin
Priority Enhancement
CurrentState No Action Required
WaitingFor
Checkins
TargetRelease n/a
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
Release01x01Checkins
Topic revision: r3 - 29 Jul 2014, StephanOsthold
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy