Support » Plugin: Relevanssi - A Better Search » Media library search not working

  • Resolved Sany

    (@sannny)


    Since Relevanssi 4.7 the media library search isn’t working anymore. If I search for a media file there are no search results.

    As you explained in Relevanssi update broke media library search function this happens when admin search is enabled and the post type attachment is not indexed.
    In my case admin search is enabled and the attachment post type is indexed.

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

    (@msaari)

    Is Relevanssi set to index image attachments? Does the search work if you disable Relevanssi in WP admin?

    Can you install the Query Monitor plugin? It would be helpful to see the MySQL query generated by Relevanssi, and Query Monitor is the easiest way to see it. The query can be found in Queries > Queries by Component > Plugin: Relevanssi and it’s the first query there.

    Thread Starter Sany

    (@sannny)

    Yes, the media search is working when I disable Relevanssi in WP admin.
    The plugin is set not to index image attachments.
    When I enable the checkbox for indexing image attachments it’s the same behaviour, also when I rebuild the index.

    The search is working at my homepage in the internet but not on the websites in intranet (same websites) – if this has something to do with this problem.

    I installed the Query Monitor plugin, the first query is the following:

    SELECT COUNT(DISTINCT(relevanssi.doc))
    FROM wp_relevanssi AS relevanssi
    WHERE (relevanssi.term LIKE '%test%')
    AND ( relevanssi.doc IN (
    SELECT DISTINCT(posts.ID)
    FROM wp_posts AS posts
    WHERE posts.post_type IN ('attachment') ) )
    AND ((relevanssi.doc IN (SELECT DISTINCT(posts.ID)
    FROM wp_posts AS posts
    WHERE posts.post_status IN ('inherit', 'private'))))
    • This reply was modified 1 year, 1 month ago by Sany.
    Plugin Author Mikko Saari

    (@msaari)

    The query looks fine, nothing wrong with that.

    If you search in the Relevanssi admin search (Dashboard > Admin search), can you find the media files there?

    Thread Starter Sany

    (@sannny)

    No, I can’t find the files there.

    I deactivated all plugins but Relevanssi and switched to a WP standard theme to make sure that it has nothing to do with my code. But there are no results, too.

    • This reply was modified 1 year, 1 month ago by Sany.
    Plugin Author Mikko Saari

    (@msaari)

    If the Relevanssi admin search can’t find the files, then this isn’t a Media Library problem, but instead an indexing issue.

    You could try the index debugging for one of the attachment posts, perhaps that will explain why the post is not indexed: https://www.relevanssi.com/knowledge-base/debugging-indexing-problems/

    If you are using a filter function on relevanssi_indexing_restriction hook, the solution is to update the filter function to use the new format for the filter hook. See here: https://www.relevanssi.com/knowledge-base/controlling-attachment-types-index/

    Thread Starter Sany

    (@sannny)

    This is the result of index debugging of an example image:

    Indexing taxonomy terms for category1 
    Indexing taxonomy terms for category2 
    Indexing taxonomy terms for category3
    Custom fields to index: field1, field2, field3, _relevanssi_pdf_content 
    Indexing post excerpt: Indexing MySQL columns. 
    Indexing PDF content for parent post. 
    Indexing post title. 
    Title, tokenized: test 
    Indexing post content. 
    Post content after relevanssi_post_content: Content, tokenized: 
    Final indexing query: 
    INSERT IGNORE INTO wp_relevanssi (doc, term, term_reverse, content, title, comment, tag, link, author, category, excerpt, taxonomy, customfield, type, taxonomy_detail, customfield_detail, mysqlcolumn) 
    VALUES (131696, 'test', REVERSE('test'), 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'attachment', '', '', 0) 

    I don’t use a filter function on relevanssi_indexing_restriction hook anymore since I recognized that I can set images not to index in the settings.
    I also tried to outcomment all filter functions that I use for Relevanssi and rebuild the index but still no search results.

    Plugin Author Mikko Saari

    (@msaari)

    Looks like you’re using Relevanssi Premium. Premium support is here, and is recommended for Premium users, if you just have a valid support license.

    Anyway, that post should now be indexed. Since you have Premium, does the “How Relevanssi sees this post” show this post as indexed? If it does, can you find it with “test”? If it’s indexed and cannot be found, then this is not an indexing problem, but a searching problem – but based on the query you originally posted, there shouldn’t be any unwanted filters in play.

    Thread Starter Sany

    (@sannny)

    Yes, I’m using Relevanssi Premium. Sorry, I forgot to mention. So the problem occurs since Relevanssi Premium 2.8.0.

    “How Relevanssi sees this post” shows the attachments as indexed. But I can’t find it.
    The queries looks fine when I copy them to dbms there is a result.
    🙁

    Thread Starter Sany

    (@sannny)

    Updating Relevanssi Premium to 2.8.2 resolves the problem.
    Thank you Mikko!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Media library search not working’ is closed to new replies.