• Hi,
    I want Relevannsi to ignore all searches with “dlm uploads”.
    In the “Indexing” tab, under “Post types” the box for “dlm uploads” is not ticked. I then built the index again.
    The link to the page I need help with shows some results to a search, the first is an example of a dlmupload.
    Any ideas how to ignore these is searches?
    thx in advance

    The page I need help with: [log in to see the link]

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

    (@msaari)

    The shortcuts_iq65_de? That’s not a dlm_upload post, that’s an attachment post. To get rid of those, don’t index attachments. If you need to index other attachments, it’s possible to control which attachments are indexed. It’s possible to filter by MIME type for example, could that be a solution?

    Oh, and looks like you might need this, if this is something of a typical search:

    add_filter( 'relevanssi_punctuation_filter', 'rlv_adjust_punctuation' );
    function rlv_adjust_punctuation( $replacements ) {
        $replacements['_'] = '';
        return $replacements;
    }

    Add this and rebuild the index. Now the “iq65_help_de” becomes “iq65 help de” when searching and that leads to lot of unnecessary results. With this filter, it becomes “iq65helpde”, with fewer results.

    Thread Starter haddlyapis

    (@haddlyapis)

    Hi Mikko,
    Filtering by MIME type could be a solution. But really, I just want to ignore the files withing the path of “/dlm_uploads/” from the relevannsi search,
    for example:
    https://www.apis.de/wp-content/uploads/dlm_uploads/2015/09/shortcuts_iq65_en.pdf
    but I do want this same file to be found here:
    https://www.apis.de/wp-content/uploads/2015/09/shortcuts_iq65_en.pdf
    Any time I upload media to my db, it goes into a folder e.g. /2020/04/…..png . But the Download Manager plugin also creates it’s own path for it if I make this attachment a downloadable link.
    thx

    Plugin Author Mikko Saari

    (@msaari)

    Since both good and bad files are PDFs, filtering by MIME type is not a solution.

    This could work:

    add_filter( 'relevanssi_indexing_restriction', 'rlv_no_dlm_uploads' );
    function rlv_no_dlm_uploads( $restriction ) {
    	global $wpdb;
    	$restriction['mysql']  .= " AND post.ID NOT IN (SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND meta_value LIKE 'dlm_uploads%' ) ";
    	$restriction['reason'] .= ' No DLM uploads';
    	return $restriction;
    }

    Add this to your theme functions.php and rebuild the index. Relevanssi should now skip all the attachments with paths that begin with dlm_uploads.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘ignore dlm uploads’ is closed to new replies.