Hello,
I would like to contribute some code to be included in the next release of Drupal. It adds search to aggregator.module

You can see it at work here: http://www.phillyfuture.org/search?keys=wifi

I believe this is a very important feature that should be part of Drupal's default aggregator.module. If you take a look at my example, it shows you just how poweful such a search can be - since it is limited by RSS feeds that are flowing thru my aggregator - it provides high quality results that are relevent to the mission of my site.

The feature was simple to add. I just added an implementation of hook_search():

/**
 * Implementation of hook_search().
 */
function aggregator_search($keys) {
	$find = array();
	
	// Replace wildcards with MySQL/PostgreSQL wildcards.
	$keys = str_replace('*', '%', $keys);
	
	$words = explode(",", $keys);
	foreach ($words as $word) {
		$word = trim($word);
		$title_filter[] = "lower(i.title) LIKE '%" . $word . "%'";
		$feed_filter[] = "lower(f.title) LIKE '%" . $word . "%'";
		$content_filter[] = "lower(i.description) LIKE '%" . $word . "%'";
	}
	$filter_query = implode(" OR ", $feed_filter) . ' OR ' .implode(" OR ", $title_filter) . ' OR ' . implode(" OR ", $content_filter);
	   
	$result = db_query_range("
		SELECT i.*, f.link AS feed_link, f.title AS feed_title, f.url AS feed_rss
		FROM {aggregator_item} i
		LEFT JOIN {aggregator_feed} f
		ON i.fid = f.fid		
		WHERE  (". $filter_query . ")
		ORDER BY timestamp DESC", 0, 20);
		
	while ($posting = db_fetch_object($result)) {	
	   $feed_title = $posting->feed_title;
	   $feed_link = $posting->feed_link;
	   $feed_rss = $posting->feed_rss;
	   $post_title = $posting->title;
	   $post_link = $posting->link;
	   $post_desc = $posting->description;
	   $post_date = date('m/d/y h:m', $posting->timestamp);
	   $find[] = array('title' => $post_title, 
	   		'link' => url("$post_link"), 
			'user' => "$post_desc<div class=\"links\">$post_date <a href=\"$feed_link\">$feed_title</a></div>");
	}
  return array(t('Matching Philadelphia blogger posts'), $find);
}

There are three important improvements that need to be made to this to make it perfect:

1. This does not utilize the stop words that are configurable for the search module. I don't know how to do that yet.

2. The header of the search results should be configurable.

3. The max number of results should be configurable.

Additionally, I would like to see the patch that Richard Eriksson developed ( http://drupal.org/files/issues/aggregator.module_4.patch) added to aggregator.module. It has allowed folks like me to display images thru the aggregator which is important for features such as this: http://www.phillyfuture.org/aggregator/categories/6

Thanks.

Comments

Steven’s picture

Contributions to core should be submitted through the issue tracker and as patches. However, note that no new features get added to old versions, and the CVS version has a significantly improved search.module. Your changes don't apply correctly anymore.

--
If you have a problem, please search before posting a question.

kmartino’s picture

Hello Steven,
I'm rather new to the Drupal community and I apoligize for not following the proceedures. I'll get them down eventually.

How do I suggest these features for the version that is in CVS? Is it to submit an issue here:

http://drupal.org/node/add/project_issue/?

Thanks.

kmartino’s picture

Here is the link: http://drupal.org/node/17627

Is there any other way I can help see this thru?

Thanks!

Steven’s picture

You can get the CVS/HEAD version yourself from the Drupal project page ("view other releases"). The module update guide and drupaldocs.org explain most of the search changes.

--
If you have a problem, please search before posting a question.

jasonwhat’s picture

kmartino’s picture

On a tip I grabbed my SQL from this module: http://drupal.org/node/13047

I think it does what you are looking for.

When I contribute my code to this project, I'm going to make sure to credit the author of news_page :)