Is it possible to index comments together with nodes? I've got a node index, and I can index the number of comments, but not the content of those comments. I'd like searches to return nodes where either the node content *or* comment content contains the search term. (I'd simply weight the node content more heavily.) I see no way to do this currently. Am I just missing it?
A huge portion of the content on this site is in the comments. I know I can create a separate index just for comments, but I don't want to search for individual comments. I want to search for nodes. Does that make sense?
Thanks much for any help.
-Joseph
Comments
Comment #1
jtbayly CreditAttribution: jtbayly commentedHere is a pertinent use-case example:
On Drupal.org, when I search the issue queue of a module, I'm not only searching the text of the original issue, but also all of the comments on that issue. That's basically what I'd like to be able to do, but I can't figure out how.
Comment #2
jtbayly CreditAttribution: jtbayly commentedclarifying title
Comment #3
jtbayly CreditAttribution: jtbayly commentedOk, now this is very ironic. I have figured out how to include node content in a comment index, but not vice-versa. Am I just missing the obvious? Certainly there must be a way to do what I want. Help?
-Joseph
Comment #4
jtbayly CreditAttribution: jtbayly commentedI guess it's not possible. Seems pretty basic to me.
I thought I was getting somewhere when I read #1068334: Add a data alteration for indexing the viewed entity . But entity_view doesn't include comments when viewing a node, so far as I can tell.
Comment #5
phreestilr CreditAttribution: phreestilr commentedNo responses to this yet...huh. I wish I could help you, but I'm actually trying to do the same thing and have not been able to figure out a way so far.
You say you can include node content in a comment index. Wouldn't that do the trick?
Comment #6
jtbayly CreditAttribution: jtbayly commentedOne would think so, but not really. Assume the word "grog" is in a post, and then there are 100 comments on that post, and you include the post data in the comment index. Now when you search for the word grog, you are going to get 100 results--one for each comment, even though they will all take you to the same page. Not very helpful in my opinion.
Please post back here if you find anything that works. I'm guessing we might have to switch to the apachesolr module, and I'm not very excited about the prospect. I just keep thinking this *has* to be possible. It seems so basic.
-Joseph
Comment #7
phreestilr CreditAttribution: phreestilr commentedYeah, you're right. It does seem like it *should* be possible, but I'm stumped. Please let me know if you figure something out, and I'll do the same.
Comment #8
jtbayly CreditAttribution: jtbayly commentedI went back and read the description of the module, and it's supposed to be able to do this, so I'm daring to switch this to a bug report. It says, "All of an entity's properties, as well as those of related entities (e.g. a node's author's name), are available as fields..." I'm pretty sure that a comment is a related entity to a node, which means that the comment content should be an available field to index. Plus, this comment indicates that it was one of the primary benefits of this module over the Apache Solr Search Integration module. But at this point, this functionality has been added over there, but is missing here.
-Joseph
P.S. It occurs to me that this could maybe be a bug with Entity API?
Edited to add, maybe it's a question of which direction the relationship between the node entity and comment entity goes? Just another guess.
Comment #9
phreestilr CreditAttribution: phreestilr commentedI've only skimmed this because I don't have time to really work on it now, but I happened upon this article, which may be of use...
http://ygerasimov.com/add-custom-field-search-api-apachesolr-index
Comment #10
drunken monkeyThis is a problem with Entity API, which doesn't include a reference to the comments in the node properties, and since we only look at those, we can't index a node's comments.
The best way to fix this would be for the Entity API to just add a "comments" property to nodes (if the comment module is enabled). If fago would be OK with that, I'd even code it. However, I can understand why they aren't included, as the relation goes from comments to nodes, not the other way round, and is thus not really part of the node in the same way that taxonomy term references are. While I think it would be cool to be able to do this, I don't know how fago'll see this.
The other way is, as mentioned in #9, to manually add this property to nodes. The linked tutorial seems pretty good to me, the official documentation, sadly, is a bit sparse.
Effectively, you'll just have to add a property "comments" to nodes and return an array containing the node's comments in the getter callback.
Comment #11
fashionary CreditAttribution: fashionary commentedI also encounter this problem and find this post.
Did anyone succeed in method proposed in comments #9 and 10?
It would be great if Drunken Monkey can code it.
Thanks for you input.
Comment #15
adams.garfield CreditAttribution: adams.garfield commentedme too having the same problem. Any solution for it yet ?
Comment #16
drunken monkeyThis is now actually a duplicate of #1414688: Add the comments property in entity_metadata_node_entity_property_info().