How hard would it be to add an RSS feed of results?

Ideally, a search would have a link to allow a RSS feed of the search for future results....

CommentFileSizeAuthor
#1 trip_search_feed.patch1.91 KBsethcohn

Comments

sethcohn’s picture

Title: RSS Feed? » RSS Feed for SQL Search - patch provided
Assigned: Unassigned » sethcohn
Status: Active » Needs review
StatusFileSize
new1.91 KB

To answer my own question of how hard would it be... the answer is quite simple.

Patch enclosed.

It needs tweaking to better fit drupal standards, but it works. Feedback and improvements welcome.

Adds a "Feed of this search" and XML icon above the search form for basic or advanced search,
and adds a new 3rd type 'feed' (so instead of trip_search/basic or trip_search/advanced, it's trip_search/feed)

There is no limit to items or correct channel info (yet), as I just wanted proof of concept, and it's quite short.

Adding this means it will now be possible to generate just about _any_ feed of content from your site, comboing ANYTHING like which users, which node types, which taxonomy, and keywords. In other words, this is the swiss army knife of RSS feeds for drupal now. Someone else should explore caching issues, etc if needed....

nedjo’s picture

Status: Needs review » Needs work

Hey, great innovation. I've tweaked the code slightly and applied it, although (blush) I haven't had a chance to try it out yet. I look forward to playing with this when I do get a chance. Likely it needs some tweaking, e.g., help text, display feed icon only when results are available, so I'm setting this to "code needs work".

Further enhancements you might have, or ideas of how to fill out the implementation, would be welcome. As you point out, using this patch, one could do create a customized feed by visiting a site, doing a search, noting the resulting feed, and then creating plugging that into another drupal instance. I'm wondering if there might be a way to combine xmlrpc and feed aggregation to enable customized feeds, without visiting the remote site. E.g., enter the url of a remote drupal instance, get a form like the advanced SQL Search form, but instead of displaying the local categories etc. it would load the remote ones.

sethcohn’s picture

It was pointed on DrupalDev that the load of this can be quite high, as feeds are often the most traffic on any site, and this is very SQL heavy. Ways to cache this better are certainly needed, for example. Bèr wants to see something like this in core, likely with major changes required to allow feeds to scale better.

One idea I had is this:

Caching by just saving 'search as feed' might be a good way to
implement this very cheaply now.... If a previous xml file exists for
'search ABC', and file is older than X minutes, do the search again
and resave it, otherwise skip the expensive SQL search and just return
the file contents. Popular feeds would be usually be file cached and
incur no SQL lookups more than X minutes apart. Unpopular feeds would
be a bit slower since the initial file lookup and save would be added
to the already needed SQL search time.

If someone implements that (shouldn't be hard), please post a patch...

P.S. (one cosmetic flaw in the above patch is an unclosed div tag. Close it after the XML link)

sethcohn’s picture

ignore the PS... nedjo fixed that (added correct theming calling too) in his application of the patch. (thanks!)
If anyone wants to play with this, just grab the cvs version now.

moshe weitzman’s picture

FYI, there is a reasonably popular standard for search results in RSS. See http://opensearch.a9.com/

sethcohn’s picture

Just to be clear, the patch is not meant to provide 'search results' (ala Opensearch), so much as a typical looking drupal feed customized based on various parameters.

It's not returning excerpts from the nodes the way the 'normal' SQL search result does, it's returning the full monty the way the other RSS feeds do now. It's living in SQL search, because it was easy to add it there since the work was 90% done, but it could easily be forked into it's own module: feed.module, and provide all the feed for drupal needs.

For instance, if you want a typical blog feed, that existed already, or if you want a feed based on a taxonomy term, those exists already... but if you want a feed based on a keyword (ala Google News alert feeds?) Or a feed based on "blogs OR stories OR audio" that a particular user authored? In other words, a feed based on a mixed combo of different aspects (yes, there are ways using nodetype+taxonomy sorting to do some of these otherwise, but not all of the possible combos you can do now)

jasonwhat’s picture

Title: RSS Feed for SQL Search - patch provided » Email alerts?

Could email alerts be added as well?

I'm starting to see a lot of overlap with this search and the "eventfinder.module" search capability. If locative searching could be included this would be great for job boards and the like. Eventfinder does allow saved searches with email, but only for event nodes. It'd be nice to have a more generalized version, perhaps combing the two.


Any luck getting the location api within search?

sethcohn’s picture

Title: Email alerts? » RSS Feed for SQL Search - patch provided

DO NOT CHANGE THE TITLE on issues - it's annoying to the rest of us.

Yes, Location searching would be nice, and yes, Eventfinder code is likely the way to go as a base. Go write a patch for it and submit it.

No, email alerts will not be added here. Go write your own patch to do that.

joel_guesclin’s picture

This looks way over my head. Is anyone still interested in adding this to 4.7?