php - How to pass function in sort parameter in solr through drupal7 hooks -
i want pass function "map" in sort parameter drupal using hooks. moto sort listing after mapping fields.
my solr server query is: http://local.host:8983/solr/collection1/select?q=%3a&sort=map(is_site_web_id%2c2%2c2%2c1%2c0)+desc&fl=site%2curl%2clabel%2cis_site_web_id&wt=json&indent=true
its working fine on solr server.
i third below code in drupal7:
function my_solr_module_apachesolr_index_document_build_node(apachesolrdocument $document, $entity, $env_id) { $document->setfield('is_site_web_id', 1); } function my_solr_module_apachesolr_query_alter($query) { $query->addparam('fl', array('is_site_web_id')); //$query->addparam('bf', array('freshness' =>'map(is_site_web_id,2,2,1,0)')); $query->setsolrsort('is_site_web_id', 'asc'); //$query->setsolrsort('map(is_site_web_id%2c2%2c2%2c1%2c0)', 'desc'); } function my_solr_module_apachesolr_query_prepare($query){ $query->setavailablesort('is_site_web_id', array('title' => t('site web id'),'default' => 'asc',)); //$query->setavailablesort('is_site_web_id', "map(is_site_web_id,2,2,1,0)"); }
when print perameters function "search" in solr_base_query.php, getting sort: [sort] => is_site_web_id asc )
i want apply condition in sorting in drupal7 using hooks: map(is_site_web_id,2,2,1,0)
i applied below code in module function:
function my_solr_module_apachesolr_query_alter($query) { $query->addparam('fl', array('is_site_web_id')); $query->addparam('sort', array('is_site_web_id' =>'map(is_site_web_id,2,2,1,0) desc')); }
and working fine. :)
Comments
Post a Comment