Closed (won't fix)
Project:
Apache Solr Search
Version:
7.x-1.8
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
7 Apr 2016 at 11:36 UTC
Updated:
12 Aug 2016 at 09:28 UTC
Jump to comment: Most recent
Comments
Comment #1
dishabhadra commenteddishabhadra created an issue.
Apache solr not having User role filter. So add new filter User Role based on that Content and User result will be shown.
Comment #2
dishabhadra commented/**
* hook_apachesolr_index_document_build().
* @param ApacheSolrDocument $document
* @param unknown $entity
* @param unknown $entity_type
* @param unknown $env_id
*/
function hook_apachesolr_index_document_build(ApacheSolrDocument $document, $entity, $entity_type, $env_id) {
$uid = $entity->uid;
$user_data = user_load($uid);
$user_role = $user_data->roles;
foreach($user_role as $role) {
$document->setMultiValue('sm_user_role', $role);
}
}
/**
* hook_apachesolr_query_alter().
* @param unknown $query
*/
function hook_apachesolr_query_alter(&$query) {
// Add the parameter.
$query->addParam('fl', 'sm_user_role');
// Add filter of user role.
$query->addFilter('sm_user_role','administrator');
}
Comment #3
dishabhadra commentedComment #4
dishabhadra commentedComment #5
dishabhadra commentedComment #6
hitesh.koliComment #7
jgrubb commentedHi dishabhadra,
The goal of this patch is to be able to search everyone who has a certain role? Search "editor" and be able to get results that are all the editors?
Comment #8
jgrubb commentedComment #9
dishabhadra commentedHi jgrubb,
Yes the goal of this patch is to get the content and user result of particular role.
Eg. If there are two roles editor and librarian. So we want the content and user data of only editor should be shown in to serach result.
The above patch will be helpful in that case.
Comment #10
jgrubb commentedHi dishabhadra, this seems like too specific a use case for this module, and would fit better in a custom module. Thank you for sharing the code to accomplish this task, though!
Comment #11
jgrubb commented