I’m working on a RSS feed where full text search has to be offered – you search from some box, and get the result as a RSS. I’ve been trying to get node_search and do_search working but I’m missing something… but what?
As far as I can tell, something like $find = node_search(‘search’, ‘type:article’); should give me a result containing all matching nodes where the type = ‘article’. But how do I specify the keyword/search term?
What am I missing?
The OpenSearch module exposes search results as RSS, no need to code it yourself.
If you want a specialised form, you can just to a redirect to the OpenSearch result after processing your form.
Addendum: If you really want do do your own, you can use
search_datalike this:This searches nodes (as the default second parameter for
search_data), but can also be used to search users and other things that have implemented hook_search.Also,
search_data, belying the name, actually returns the formatted search results. If you want to have the raw search results, you can invokehook_searchdirectly, or usedo_search. Examples:The difference being is that invoking the hook gives you a lot more node-related data (since it runs through the node-specific search code, in addtion to the generic
do_search(node.module’shook_searchimplementation calls do_search to get the actual work done)) and a possibly more accurate search, since the node search respects the weights you might have set in the search settings. The tradeoff is a slower search query.