Is there a way to manually call Apache solr search on a page? I know how to do that for the drupal search. This is the code I used to pull in the parameters and get the search results

$searchKey = str_replace(" ","+",$_REQUEST['searchKey']);
$result = node_search('search', $searchKey);

So the url would look something like this. www.example.com/results?searchKey=test

This works for the drupal search. However, this doesn't use the search from Apache solr. So is there anyway I can pass in parameters and pull in the search results using the apache solr module?

Comments

jbunyan’s picture

So I used the hook_search function from the apache solr module.
$result = apachesolr_search_search('search', $searchKey);
And it pulls in the search results that I wanted. Do you think this will be a problem in a live environment.

pwolanin’s picture

Status: Active » Fixed

It should be ok - that's what the module itself is using, of course. However, you may need to go deeper in the API if you want more control.

jbunyan’s picture

Thanks for the information. I wasn't sure if it was good Drupal practice, but it was the only thing that worked for me. So 10 search results show. If I include this in the URL ?page=2, I get the next set of results. So is it possible to pull in the correct pager for the search results. I"m not too familar with pager functions. Would pager(),theme_pager(), or pager_query() give me what I want?

nick_vh’s picture

Status: Fixed » Closed (fixed)

Normal pager would certainly give you what you would expect. Normally just use theme('pager') if you want to get a normal pager. Take a look at how the module theme's its pages and it should help you further :-)