I am working in Drupal 6 website with apachesolr. I have added a cck field (text field) in a content type.

When I am searching the value of textfield, apachesolr showing empty result.

The field is indexed properly into apachesolr index.

How can I implement apachesolr searching for cck text field?

1 Answer 1


Once you add a CCK field then the CCK will not by default get indexed. You have to delete all the existing index and have to re-index all items. This is because, CCK fields are properties of all the documents (nodes) that goes to the SOLR index.

Once all the items are index then you can find those by sis_cck_field_* names where sis_* is a type of dynamic field provided by SOLR itself. You can find the CCK index status in admin/reports/apachesolr/index page or in SOLR admin ( page.

EDIT -- 1 As mentioned, the field is indexed properly then try to search by the value of the CCK field in Apache Solr's admin search (http://localhost:8983/solr/admin/form.jsp). If you see the search results appear as per your desire then there may be a permission issue. If your field is called "field_example" then in permission page check whether "view field_example" is checked for desired roles.

Edit -- 2 In that case I think the cck field is not at all being indexed. I had the same problem once with CCk fields that stores "multiple" values. In that case what I had to do is to create a new field in SOLR index and index the item again. This may solve your problem but may not be a proper way. However you will find this way is excepted in Drupal also in this link.

You have 2 ways to achieve this.

  1. Append the item in the body field in time of content indexing hook.
  2. Add a new dynamic field to the document object while indexing and fetch the field while searching.

For the 1st one,

function MYMODULE_apachesolr_update_index(&$document, $node, $namespace) {
  $document->body .= ' '. $node->field_MY_CCK_FIELD[0]['view'];

For the 2nd one,

function MYMODULE_apachesolr_update_index(&$document, $node, $namespace) {
  // For multiple values.
  foreach ($array as $value) {
    $document->setMultiValue('sm_multiple_value', $value);
  // For text field.
  $document->addField('ts_element_name', $value);

And while searching,

function MYMODULE_apachesolr_modify_query(&$query, &$params, $caller) {
  $params['fl'] .= ',ts_element_name'; //Add the field name to the select query.
  • Field is indexed properly into apache solr. Commented Jul 15, 2014 at 10:36
  • An edit added to the answer, check and let me know Jayendra. Commented Jul 15, 2014 at 10:43
  • I have checked solr admin and use select query and found that there is no data for field but its showing field in admin/reports/apachesolr. Commented Jul 15, 2014 at 11:04
  • I see, have a look at the edit #2. Hope this will be helpful for you. Commented Jul 15, 2014 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.