1779 Posts in 582 Topics by 556 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2510 Views |
-
Limiting Search Results

24 March 2009 at 5:31pm Last edited: 24 March 2009 5:33pm
Hi,
Just how is the silverstripe search doing it's thing. I went through the tutorial a long time ago and it works OK. But now my client is complaining as the results are:
1. Fairly inaccurate
2. Don't display a first paragraph of content as per the tutorial.
3. Including searches through the entire Upload directory (PDF and Doc). These ones in particular are destroying the look of the result page, as the content returned contains weird spacing.All I can see in the code is this function in Page.php:
function results($data, $form){
$data = array(
'Results' => $form->getResults(),
'Query' => $form->getSearchQuery(),
'Title' => 'Viva Expeditions Search Results'
);
return $this->customise($data)->renderWith(array('Page_results', 'Page'));
}Three key questions:
1. How exactly is that code doing the entire search?
2. How do I tell it to stay out of my Uploads directory?
3. I haven't heard a peep about the new search system in 2.3, although I it appears to be built in. Will I have more luck with a 2.2 to 2.3 upgrade? Is there documentation for this if it has changed?Cheers
Aaron -
Re: Limiting Search Results

29 March 2009 at 3:20pm
Have a look at the SearchForm class, thats where everything happens.
No big changes since 2.2 for this, though. You'd need to subclass this and adjust
to your needs - e.g. not to query File/Image subclasses.We've got a bunch of tickets in the queue concerning a new search implementation:
http://open.silverstripe.com/ticket/3200
http://open.silverstripe.com/ticket/3147
http://open.silverstripe.com/ticket/3331
http://open.silverstripe.com/ticket/3703 -
Re: Limiting Search Results

7 August 2009 at 1:58pm
A quick and easy fix if you don't want images returned in your search results.
function results($data, $form){
$results = $form->getResults();
foreach($results AS $result) {
if($result->ClassName == "Image") $results->remove($result);
}$data = array(
'Results' => $results,
'Query' => $form->getSearchQuery(),
'Title' => 'Search Results'
);return $this->customise($data)->renderWith(array('Page_results', 'Page'));
} -
Re: Limiting Search Results

1 September 2009 at 3:30am
Hey,
Cool fix, I was a little concerned that the contents of my assets folder was being shown in search results. One extra tweak I made was removal of the 'file' class from the results as well:
if($result->ClassName == "File") $results->remove($result);
Just in case that's any help to anyone.
Alex
-
Re: Limiting Search Results

1 February 2010 at 6:11am
Also,
Useful to remove folders from results too, again, the uploads folder was being listed, which didn't work for me.
if($result->ClassName == "Folder") $results->remove($result);
Alex
| 2510 Views | ||
|
Page:
1
|
Go to Top |




