Selvam S
January 5, 2013
Search plays a crucial role in content-driven websites. Drupal and the Open-source enterprise search platform Solr form an effective combination. Drupal 7 has an apachesolr module that integrates Drupal with the Apache Solr search platform. I am going to detail how to alter the solr query to get better and more precise results.
function MODULE_search_apachesolr_query_prepare($query) {
$compiled_filter = new SolrFilterSubQuery('OR');
$compiled_filter->addFilter('bundle', 'student');
$compiled_filter->addFilter('bundle', 'teacher');
$query->addFilterSubQuery($compiled_filter);
}
$filter2 = new SolrFilterSubQuery('AND');
$filter2->addFilter('bundle', 'student');
$filter2->addFilter('dm_field_student_validity','[NOW TO *]');
It receives the students who have validity date not lesser than current date. You can nest multiple filters,
function MODULE_apachesolr_query_prepare($query) {
$filter = new SolrFilterSubQuery('AND');
$filter->addFilter('bundle', 'student');
$filter->addFilter('dm_field_student_validity','[NOW TO *]');
$compiled_filter = new SolrFilterSubQuery('OR');
$compiled_filter->addFilter('bundle', 'teacher');
$compiled_filter->addFilterSubQuery($filter);
$query->addFilterSubQuery($compiled_filter);
}
Just like how your fellow techies do.
We'd love to talk about how we can work together
Take control of your AWS cloud costs that enables you to grow!