Execute the query from search_api_views directly on the SOLR server

Public

If Views is too slow or if you just need a complete set of entity_ids based on a (very large) view.

You can directly query the SOLR server as follows, assuming you have the complete $view object. This will convert a SearchApiViewsQuery object to a SearchApiQuery object first and then execute this query directly on the SOLR server. Of course you can set the limits and offsets or additional filters directly on the SearchApiQuery object.

More examples on how to use the SearchApiQuery can be found here:
http://drupal.stackexchange.com/questions/74505/how-to-send-a-custom-sol...

Get raw version
php
  1. // First set a views object.
  2. $view = views_get_current_view();
  3. $SearchApiViewsQueryObject = $view->query;
  4.  
  5. // Manually set the server.
  6. $server_name = 'solr';
  7. $server = search_api_server_load($server_name);
  8.  
  9. // Rebuild the SearchApiViewsQuery Object to a SearchApiQuery Object.
  10. $SearchApiQuery = $SearchApiViewsQueryObject->getSearchApiQuery();
  11.  
  12. // If you need to adjust filters, use this class:
  13. // $SearchApiQueryFilter = $SearchApiQuery->getFilter();
  14.  
  15. // Lets set this to an unusual high number, like: 1 million, if this is more
  16. // we can create a loop with offset and limit in the future.
  17. $SearchApiQuery->setOption('offset', (int) 0);
  18. $SearchApiQuery->setOption('limit', '1000000');
  19.  
  20. $solr = new SearchApiSolrService($server);
  21. $result = $solr->search($SearchApiQuery);
  22.  
  23. $entity_ids = array_keys($result['results']);