It appears to me that apachesolr_search only indexes the count of comments but not the comment text itself.

Has anyone started work on this as a feature?

Comments

drunken monkey’s picture

Status: Active » Fixed

This is already done. Since the comment module implements hook_nodeapi(), the call node_invoke_nodeapi($node, 'update index') in ApacheSolrUpdate::update_index() with the subsequent adding of the results to $text adds all comments with subject to the Solr 'text' field.

To verify this, just search at my demo site for "Google" or "Counterpart", both of which only appear in a comment.

janusman’s picture

Perhaps users are expecting the snippet in search results to show whatever text that matched, but currently we are only showing a snippet of the node body in apachesolr_search.module

$snippet = search_excerpt($keys, $doc->body)

I guess putting in any more information would be a performance hit (either storing more stuff in the solr document "body", calling node_load(), etc.) but I'm not sure how much.

mattconnolly’s picture

Status: Fixed » Active

Sorry if I'm reopening this incorrectly, but I'm not seeing any search results from comments in my search site.

If it's done already, how does the comment text make its way into the solr index? (I can't see that code anywhere...)

I thought you would have invoked the nodeapi('update index') on the node so that other modules can return data that would be added to the "text" field of the indexed document (in ApacheSolrUpdate::update_index ).

drunken monkey’s picture

Have you really tried it? Add a comment to a node with words in it that appear nowhere else, then run cron and search for them.
If you've done that and the result does not appear, then it's a bug report, otherwise it's fixed. In any case, please mark this issue accordingly.

The module does call the nodeapi, it's in line 211 of apachesolr.module, for the alpha3 release.

mattconnolly’s picture

Status: Active » Fixed

You're right, the nodeapi call does it. I must have forgotten to run cron when I tested it last, because it does indeed work.

Thanks for getting me to double check it!

There is, however, a SOLR bug involved that got me. I'm using the HTMLStripStandardTokenizerFactory in my solr schema for the 'text' field. If i log the "text" field of the document as it is indexed I can definitely see the comments in there. But, what happens is, the comment appears like this;

<h2>title</h2><p>comment</p>

Which is stripped to "titlecomment" not "title comment" like it should. (I copied the text and pasted it into the SOLR analyser to prove it.) I don't know how long SOLR bugs take to fix and filter through to all the users here, but this hack in the apachesolr module works around the bug.

$text = preg_replace('@(</p>|</h\d>|<br[^>]*>|</div>|<hr[^>]*>)@im', "\\1 \n", $text);

Just before $document->text = $text.

-Matt

robertdouglass’s picture

Matt, thanks for catching the "no space" bug. It'd be nice to change this in core, too. /me puts it on TODO list.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.