1

I am trying to load full facet blocks on non search page to put them in cache.

What I am doing is looping through items with taxonomy $tid, then

$params = array('fq' => 'tid:' . $tid); $current_query = apachesolr_drupal_query('apachesolr', $params, '', 'search/site'); $response = apachesolr_do_query($current_query); $facet_block = module_invoke('facetapi', 'block_view', $block_id); 

When I dsm $response->request, on each iteration I always see the first $tid in the query string ("q.alt=tid..."). The result I get is the same block for every terms, on each apachesolr_do_query requests.

Anyone got a clue on what is going on there ? The purpose of this is to generate cached facet blocks from non search pages, for several tid as the apache solr search parameter.

1 Answer 1

1

The problem is, apachesolr_do_query checks if a query has already been made:

apachesolr.module line 1470 :

 // Verify if this query was already executed in the same page load if ($response = apachesolr_static_response_cache($searcher)) { // Return cached query object return array($query, $response); } 

So, all you have to do to process multiple ApacheSolr queries is to reset the Drupal static variable like so:

drupal_static_reset('apachesolr_static_response_cache'); 
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.