How to filterByAttribute?

Permalink
I'm overriding the 'search' block and want to filter by custom page attributes, e.g. attribute handle = 'continent' and the attribute value = 'Europe', attribute type is 'select', so (for testing purposes I put explicit values, rather than those from a form) my code is
$ipl->filterByAttribute('continent', '%Europe%', 'like');


but I get this error
An unexpected error occurred.
mysql error: [1054: Unknown column 'cIndexScore' in 'order clause'] in EXECUTE("select p1.cID, pt.ctHandle from Pages p1 left join Pages p2 on (p1.cPointerID = p2.cID) left join PageTypes pt on (pt.ctID = (if (p2.cID is null, p1.ctID, p2.cID))) left join PagePaths on (PagePaths.cID = p1.cID and PagePaths.ppIsCanonical = 1) left join PageSearchIndex psi on (psi.cID = if(p2.cID is null, p1.cID, p2.cID)) inner join CollectionVersions cv on (cv.cID = if(p2.cID is null, p1.cID, p2.cID) and cvID = (select max(cvID) from CollectionVersions where cID = cv.cID)) inner join Collections c on (c.cID = if(p2.cID is null, p1.cID, p2.cID)) left join CollectionSearchIndexAttributes on (CollectionSearchIndexAttributes.cID = if (p2.cID is null, p1.cID, p2.cID)) where 1=1 and cvIsApproved = '1' and (p1.cIsTemplate = 0 or p2.cIsTemplate = 0) and (((select count(cID) from PagePermissions pp1 where pp1.cID = if(p2.cID is null, p1.cInheritPermissionsFromCID, p2.cInheritPermissionsFromCID) and pp1.cgPermissions like 'r%' and (pp1.gID in (1) or pp1.uID = -1))) > 0 or (p1.cPointerExternalLink !='' AND p1.cPointerExternalLink IS NOT NULL)) and ak_continent like '%Europe%' and (p1.cID not in (5,6,7,8,10,11,12,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,46,47,48,49,50,51,52,53,54,55) or p2.cID not in (5,6,7,8,10,11,12,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,46,47,48,49,50,51,52,53,54,55)) order by cIndexScore desc, cDatePublic desc limit 0,20 ")

What does this mean? Thank you.

linuxoid
 
linuxoid replied on at Permalink Reply
linuxoid
Oh, just had a look at the /monel/page_list.php and it doesn't seem to have a filterByAttribute function. And there's no IndexedPageList class there either. Could that be the problem? Please give an axample how I can use filterByAttribute. At the moment I have this in my controller:
function do_search() {
      $q = $_REQUEST['query'];
      Loader::library('database_indexed_search');
      $ipl = new IndexedPageList();
      //$ipl->filterByKeywords($q);
      $ipl->filterByAttribute('continent', 'Europe', 'like');
      if( is_array($_REQUEST['search_paths']) ){ 
         foreach($_REQUEST['search_paths'] as $path) {
            //if(!strlen($path)) continue;
            $ipl->addSearchPath($path);
         }
      }
      $res = $ipl->getPage(); 
      foreach($res as $r) { 
         $results[] = new IndexedSearchResult($r['cID'], $r['cName'], $r['cDescription'], $r['score'], $r['cPath'], $r['content']);

Thank you.
linuxoid replied on at Permalink Reply
linuxoid
Now I've tried this:
function do_search() {
      $q = $_REQUEST['query'];
      $length = $_REQUEST['length'];
      $continent = $_REQUEST['continent'];
      $adventure = $_REQUEST['adventure'];
      $interest = $_REQUEST['interest'];
      $attributeKeyHandle = 'continent';
      //Loader::library('database_indexed_search');
      //$ipl = new IndexedPageList();
      //$ipl->filterByKeywords($q);
      Loader::model('page_list');
      $ipl = new PageList();
      $ipl->filterByAttribute($attributeKeyHandle, '%' . $continent . '%', 'like');
      if( is_array($_REQUEST['search_paths']) ){ 
         foreach($_REQUEST['search_paths'] as $path) {

and I have this error: "Fatal error: Class 'IndexedSearchResult' not found in /srv/www/htdocs/c5/blocks/search/controller.php on line 153"