3063 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 784 Views |
-
modify search engine

21 December 2010 at 4:13am Last edited: 21 December 2010 4:19am
Hi
I'm tring to mofidy search engine to add other fields
I have "Product" page with fields: 'content' and 'technical information'
first i added Product to classesToSearch in SearchForm action
function SearchForm() {
$searchText = isset($this->Query) ? $this->Query : 'Znajdź produkt';
$fields = new FieldSet(
new TextField("Search", "", $searchText)
);
$actions = new FieldSet(
new FormAction('results', 'szukaj')
);$form = new SearchForm($this, "SearchForm", $fields, $actions);
$form->classesToSearch(array('SiteTree', 'Product'));return $form;
}next modified SearchForm.php like that:
/**
* Classes to search
*/
protected $classesToSearch = array("SiteTree", "Product", "File");function classesToSearch($classes) {
$illegalClasses = array_diff($classes, array('SiteTree', 'Product', 'File'));
..
$legalClasses = array_intersect($classes, array('SiteTree', 'Product', 'File'));public function searchEngine(..............) {
$extraFilters = array('SiteTree' => '', 'Product'=>'', 'File' => '');.....
if($keywords) {
$match['Product'] = "MATCH (Content, TechnicalInformation) AGAINST ('$keywords') AND ClassName = 'Product'";
$relevance['Product'] = "MATCH (Content, TechnicalInformation) AGAINST ('$relevanceKeywords' IN BOOLEAN MODE)";
}// Generate initial queries and base table names
$baseClasses = array('SiteTree' => '', 'Product'=>'', 'File' => '');foreach($this->classesToSearch as $class) {
...
$baseClasses['Product'] = '`Product_live`';
}// Make column selection lists
$select = array(
'Product' => array("ClassName", "$baseClasses[Product].ID","_utf8'' AS ParentID","Content","TechnicalInformation", "$relevance[Product] AS Relevance", "NULL AS CanViewType"),
)foreach($queries as $query) {
$querySQLs[] = $query->sql();
//$totalCount += $query->unlimitedRowCount(); (comented)
}}
}and i don't know why but i get error
[User Error] Couldn't run query: SELECT ClassName, `Product_live`.ID, _utf8'' AS ParentID, Content,TechnicalInformation, MATCH (Content,TechnicalInformation) AGAINST ('something' IN BOOLEAN MODE) AS Relevance, NULL AS CanViewType FROM `Product_live` WHERE (MATCH (Content,TechnicalInformation) AGAINST ('something*') AND ClassName = 'Product') AND (`SiteTree_Live`.ClassName IN ('Product')) ORDER BY Relevance DESC LIMIT 0, 10 Unknown column 'SiteTree_Live.ClassName' in 'where clause'
what is this 'AND (`SiteTree_Live`.ClassName IN ('Product'))' and how to fix it ?
-
Re: modify search engine

4 March 2011 at 11:31pm
hello do you solve the problem and if the answer is yes, please write how do you modify search engine!
with regards
ntrumax
| 784 Views | ||
|
Page:
1
|
Go to Top |

