How do I render the search form for a particular Apache SOLR search page on its own? I have the SOLR search module installed, and have set up a couple of different search pages.

I need to render the form for one of these pages on a separate page. I thought I could just piggy back off the default search_form(), but it doesn't work.

Using this code:

$build['search_form'] = drupal_get_form('search_form', 'directory/search', '', 'apachesolr_search');


The search form is displayed, and has the correct action property. But when the form is submitted, it just redirects to directory/search, without the keys in the URL (which are obviously required for the search).

What am I missing?
Well I'm not sure what the problem was, but after a bit of further digging into apachesolr_search I've come up with a work around which seems to do the trick:

$search_page = apachesolr_search_page_load('PAGE_ID');

module_load_include('inc', 'apachesolr_search', 'apachesolr_search.pages');
$build['search_form'] = drupal_get_form('apachesolr_search_custom_page_search_form', $search_page);


As kiamlaluno has noted in the comments it doesn't look like it's actually apachesolr_saerch causing this behaviour, but rather the core search module doing...something.

Hopefully this code will save someone the time in the future.