1

I need on my site a search. It should index the comments too, fulltext index is fine, they could be seen as part of body.

But as I use workbench with many steps, most nodes are unpublished. And I guess that ist not possible with builtin search.

So I checked search_api and it works for all content and its fields but NOT the comments.

Any suggestions what I could try?

3
  • According to this Comments are automatically indexed and for search purposes are considered part of the node to which they are attached. – Felix Eve Apr 1 '14 at 15:34
  • but only in published nodes afaik... – groovehunter Apr 1 '14 at 15:46
  • Arr - of course, got ya. But won't most nodes that have comments already be published? – Felix Eve Apr 1 '14 at 15:48
1

You can use hook_searchapi_entity_property_info_alter:

function mymodule_searchapi_entity_property_info_alter(&$info) {
    if (isset($info['node']['bundles'])) {
        // For each content type.
        foreach ($info['node']['bundles'] as $bundle_type => $bundle) {
                $info['node']['bundles'][$bundle_type]['properties']['comments'] = array(
                    'label' => 'node comments',
                    'description' => 'the comments of the node',
                    'type' => 'text', // or whatever you want here
                    'getter callback' => 'mymodule_searchapi_get_whatever', // name me whatever you want

                );
            }
        }
    }
}

and your callback

function mymodule_searchapi_get_whatever($entity, $options, $name, $entity_type, &$info) {
    // return the comments here, as you have everything in the function variables - i.e. use return.
}

Look at example implemntations of this hook and it should be enough to get your started.

1
  • I am not ready with this issue yet... hopefully I can try your suggestion soon. – groovehunter Jun 17 '14 at 13:42
0

Have you worked before https://drupal.org/project/views_bulk_operations module.. If not just try it. it provides to create custom filter based on various relation in a format of view where you can add all types of filter from admin/backend.

Just try it.

0

I found the search_api (plus search_api_db) sufficient. I use the search_api_views also FYI

in node index -> fields I add at the bottom another relationship and Comment->body extra

AND of course in the filter: Do not check "exclude unpublished nodes".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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