• Resolved rossvtec

    (@rossvtec)


    I’m using this plugin to search custom post type and custom post type comments. When you do a search on some comments results it would a comment title to the begging of the description are, so it would look something like this:

    A Question Title on Top
    commentauthor The description goes here.

    Also some post seem to not get indexed. When you search by par of their title or comment, no results are found.

    https://www.ads-software.com/plugins/relevanssi/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Yes, the comment author gets there, because Relevanssi indexes the author as well. There’s isn’t a good solution for this at the moment, I’m afraid.

    When you say “part of the title”, can you give me a concrete example of a search and a title that the search doesn’t find?

    Thread Starter rossvtec

    (@rossvtec)

    Is there a way to make comment author not be indexed?

    So if title is “This is a test question title” and you search for “test question” nothing comes up, or if you search and part of that post it doesn’t come up as if it didn’t get indexed. However a post before it or after it comes up in the search fine if you search for it.

    Also another thing i noticed. If i search for a string congaing “the” word in results it will highlight words “the” even when “the” is part of another word (ie “other”). And I have added “the” word to the list of stop word list.

    Plugin Author Mikko Saari

    (@msaari)

    Well, you can use the relevanssi_comment_content_to_index filter to adjust what gets indexed for comments. The author is always the first thing on the string, so you can remove that (if you can figure out a way to tell which part is the author and which part is the content). Looks like I’ll need to figure out some filters to make this easier.

    If the post cannot be found with any words, then yes, it’s probably not in the index. Why, it’s impossible for me to tell. Rebuilding the index is the first thing to try – does that solve the problem?

    Thread Starter rossvtec

    (@rossvtec)

    How would I use relevanssi_comment_content_to_index filter to remove comment author, do you have an example?

    Plugin Author Mikko Saari

    (@msaari)

    Something like this:

    add_filter('relevanssi_comment_content_to_index', 'rlv_com_con');
    function rlv_com_con($comment) {
         return $comment;
    }

    $comment contains the comment in the format “author comment_content comment_id”. You could pick up the comment id from the end, then use that to find the author name, then remove that from the beginning… Or something like that.

    Thread Starter rossvtec

    (@rossvtec)

    When i do the following:

    add_filter(‘relevanssi_comment_content_to_index’, ‘rlv_com_con’);
    function rlv_com_con($comment) {
    var_dump($comment);
    //return $comment;
    }
    I get something like this (with a space at the end, no id)
    string(91) “comment_author Lorem ipsum dolor sit amet, ei liber partem hendrerit est, sanctus laoreet no pri. ”

    Plugin Author Mikko Saari

    (@msaari)

    Hard to say – the comment ID should be there. I’ll have to debug this and see if the function is working correctly, but just looking at the source code I don’t see a problem.

    Thread Starter rossvtec

    (@rossvtec)

    Here is how I fixed the issue of author showing up with the excerpt in case anyone is having the same issue.
    In wp-content/plugins/relevanssi/lib/indexing.php on line 694 I changed
    $comment_string .= apply_filters('relevanssi_comment_content_to_index', $comment->comment_author . ' ' . $comment->comment_content . ' ', $comment->comment_ID);
    to
    $comment_string .= apply_filters('relevanssi_comment_content_to_index', $comment->comment_content );

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Comment Author gets added to search results excerpt’ is closed to new replies.