By asghar on
Hi guys
Same as drupal 6 you can index your custom fields in apachesolr . Here is some code by modifing this you can index your fields in apachesolr.
function mymodule_apachesolr_index_document_build(ApacheSolrDocument $document, $entity, $entity_type, $env_id) {
if ($node->type == 'job') {
$contacts = array();
if ( count ($node->field_job_title)) {
$document->setMultiValue('ss_field_job_title', $node->field_job_title['und'][0]['value']);
}
}
/**
* Implementation of hook_apachesolr_query_alter($query)
*/
function mymodule_apachesolr_query_alter($query) {
//$query->addFilter("ss_field_job_title");
$query->addParams(array('fl' => array(
'ss_field_job_title'
)));
}
Comments
Great!
How can I index custom USER field?
I suggest a Google limited to drupal.org
I do not have your answer,
but I know how to use Google and limit the search to drupal.org
since the d.o search is essentially worthless to me
except maybe when I am in a specific project's
(module's or theme's) issues que.
Google Search: site:drupal.org
https://www.google.com/webhp?q=site%3Adrupal.org+
Note 1: Do Not insert a blank-space after the colon (":") before the first letter of the domain name ("drupal.org").
Note 2: Type a blank-space following the plus-sign (+),
and add your keyword(s) &/or "keyword phrase"(s).
Wrap a multi-word keyword phrase in double-quotes ("... ... ... ")
to search for exact phrase matching in the search.
Sample Google search of d.o
Example using keyword(s): index custom USER field
https://www.google.com/search?q=site%3Adrupal.org+index+custom+USER+field
.
.
All the best; intended.
-Chris (great-grandpa.com)
___
"The number one stated objective for Drupal is improving usability." ~Dries Buytaert *
Works for me....!!
That works for me tooo.....!!
t@n
[Solved] changing $node->type to $entity->type worked for D7
function yourmodulename_apachesolr_index_document_build(ApacheSolrDocument $document, $entity, $entity_type, $env_id) {
if ($entity->type == 'test') {
$contacts = array();
if ( count ($entity->field_test_cck)) {
$document->setMultiValue('ss_field_test_cck', $entity->field_test_cck['und'][0]['value']);
}
}
}
/**
* Implementation of hook_apachesolr_query_alter($query)
*/
function yourmodulename_apachesolr_query_alter($query) {
//$query->addFilter("ss_field_job_title");
$query->addParams(array('fl' => array(
'ss_field_test_cck'
)));
}