- b2evolution CMS Support Forums
- b2evolution Support
- General Support
- [1.9.x] Is it possible to change the fields that SEARCH uses
1 michaelis_rex Feb 21, 2007 15:58
My b2evolution Version: 1.9.x
Apologies if this is described elsewhere, but I couldn't find it looking through the FAQs or using the search form.
I am running b2evolution 1.9.2. The "search" feature seems to search the main text of blog postings, i.e., the contents of evo_posts.post_content. For my purposes, I would prefer to have search operate on posting titles, i.e., the evo_posts.post_title field instead of evo_posts.post_content.
I've done some grepping in the ../blogs/inc/_misc directory. I think that the field(s) to be searched might be specifiable in a class constructor in the file _sql.class.php. However, I'm not certain I understand the basic architecture by which the search engine works, and I'm even less certain of where the constructor is invoked, and of the form in which parameters need to be given in order to alter the default search field (if it's even possible).
Is this documented somewhere that I just haven't found yet, or can someone knowledgeable about the underlying architecture of the search engine advise me on how I might tweak b2evolution to search posting titles instead of posting content?
Thanx,
Mike Watson
Seems like I've spent forever hunting for it, but I think I found the solution! I'm still testing it, but it seems to have solved the problem. I'm posting it here in case somebody else wants to do something similar in the future.
It looks like it's hard-coded in blogs\inc\MODEL\items\_itemquery.class.php that keyword searches will operate on both post_title _AND_ post_content:
$search .= ' '. $join. ' ( ('.$this->dbprefix.'title LIKE \''. $n. $DB->escape($keyword_array[$i]). $n. '\')
OR ('.$this->dbprefix.'content LIKE \''. $n. $DB->escape($keyword_array[$i]). $n.'\') ) ';
This logical structure appears twice: once for "word" searches, and once for "sentence" searches. By removing the second clause, i.e., deleting this:
OR ('.$this->dbprefix.'content LIKE \''. $n. $DB->escape($keyword_array[$i]). $n.'\') ) ';
I did run into some sql problems by not paying attention to balancing the parentheses and closing the quotes properly, but I was eventually able to get that figured out.