[TYPO3-english] Solr faceting and categories: restrict results per (set of) category

Bert Bert
Sun Nov 1 19:08:31 CET 2015


Hello Jigal,

Thanks for your reply...

I think I understand what you mean...
Since I would to make condition with TS, I tested the following, based on:
plugin.tx_solr.search.query.filter{
  /*
   formula: myFilter = field:value
  */
}

Test 1:
plugin.tx_solr.search.query.filter{
  pagesOnlyFilter=type:pages
}
Works, only show results from "pages"!

Test 2:
plugin.tx_solr.search.query.filter{
  newsOnly=altType_stringS:Noticias
}
Works, only show results as defined under "Noticias"!

Test 3:
plugin.tx_solr.search.query.filter{
  categoryFilter=category_stringM:963
  #where  '963' is the facetKey (see below)...
}
Does not work, that is, no results found while there are results from 
that category...

Any idea what I am doing wrong in case of category filter?

Thanks again and regards!
-brt




...
     faceting = 1
     faceting {

       removeFacetLinkText = <b>@facetText</b>
       facets {
         type >
         altType_stringS {
           field = altType_stringS
           label = Recurso
           #operator = OR
         }
         category_stringM {
           label = Categorias
           field = category_stringM
           type = hierarchy
           hierarchy = HMENU
           hierarchy {
             1 = TMENU
             1 {
               NO = 1
               NO {
                 doNotLinkIt.stdWrap.cObject = TEXT
                 doNotLinkIt.stdWrap.cObject {
                   override=1
                   override.if.isInList.field = facetKey 
override.if.value=963,276,237,544,358,307,1743
                 }
                 wrapItemAndSub = <li>|</li>
                 stdWrap.htmlSpecialChars = 1
                 stdWrap.cObject = RECORDS
                 stdWrap.cObject {
                   source.field = facetKey
                   tables = sys_category
                   dontCheckPid = 1
                   conf.sys_category = TEXT
                   conf.sys_category.field = title
                   conf.sys_category.htmlSpecialChars = 1
                 }
                 stdWrap.dataWrap = <a class="btn btn-default 
dropdown-toggle btn-select" data-toggle="dropdown" href="#">|<span 
class="facetoption-result-count">&nbsp;({field:numberOfResults})&nbsp;</span><span 
class="caret"></span></a>
               }
             }

             2 < .1
             2.wrap = <ul class="dropdown-menu">|</ul>
             2.NO.stdWrap.dataWrap = |<span 
class="facetoption-result-count">&nbsp;({field:numberOfResults})&nbsp;</span>
           }
         }
       }
     }
...



On 01/11/15 13:34, Jigal van Hemert wrote:
> Hi,
>
> On 01/11/2015 10:13, Bert Hiddink [BENDOO e-work solutions] wrote:
>> I have succesfully set up Solr with categories/faceting thanks to this
>> article of Steffen Ritter:
>> http://blog.steffen-ritter.net/2014/04/extsolr-use-categories-as-hierarchical-facets/
>>
>>
>>
>> However, now I want to restrict the rendering of the results to a
>> specific set of categories, depending on the page where the searchbox is
>> placed.
>>
>> How could I restrict the rendering of categories in the case of
>> "type=hierarchy")?
>
> The categories are properties of the solr documents in the result set.
> The facets that are rendered simply reflect the categories that are
> present in the result set.
> By saying that you want to restrict the displayed set of categories I
> assume that you actually want to restrict the result set (depending on
> the page where the search box is placed)?
>
> The solr plugin provides some options to set for example a filter query.
> If you e.g. want to restrict the items to one top level category you
> could put the top level category/categories in a field in the index and
> put a filter query for that category in the plugin configuration (or do
> it with TypoScript, perhaps using some data depending on the page and
> make it work automatically).
> As a side effect the search result would be limited to items with those
> categories and the facet automatically only shows the categories you want.
>



More information about the TYPO3-english mailing list