Support » Plugin: Relevanssi - A Better Search » “Exact phrase” search terms are not searching taxonomies

  • We’ve got a site where Relevanssi is working beautifully for the most part. The only current issue is that some users like to search with quote marks for exact phrases. This means that they aren’t able to see results from taxonomies.

    As an example, we might a custom post type of People who have taxonomy of Job Type. One of the Job Types is Web Developer. If the user searches for web developer then they see some People in the results. If they search for "web developer" then it returns no People in the results.

    I’ve looked in the admin search console and I get the same results there.

    Any help/pointers would be very much appreciated.

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

    (@msaari)

    Relevanssi phrase matching should apply to taxonomy names for taxonomies that are set to be indexed.

    Check the MySQL queries Relevanssi is doing. There should be something that looks like

    (SELECT ID FROM wp_posts as p, wp_term_relationships as r, wp_term_taxonomy as s, wp_terms as t WHERE r.term_taxonomy_id = s.term_taxonomy_id AND s.term_id = t.term_id AND p.ID = r.object_id AND s.taxonomy IN (your indexed taxonomies) AND t.name LIKE '%web developer%' AND p.post_status IN ('publish','private','draft','inherit'))

    Is there?

    Thread Starter jwarren

    (@jwarren)

    @msaari When I search for "web developer", there absolutely is:

    (SELECT ID FROM wp_posts as p, wp_term_relationships as r, wp_term_taxonomy as s, wp_terms as t WHERE r.term_taxonomy_id = s.term_taxonomy_id AND s.term_id = t.term_id AND p.ID = r.object_id AND s.taxonomy IN ('category','people_position') AND t.name LIKE '%web developer%' AND p.post_status IN ('publish','draft','private','pending','future','inherit'))

    It’s part of a much larger query. There aer several queries very similar to this one:

    SELECT DISTINCT(relevanssi.doc), relevanssi.*, relevanssi.title * 15 +
    				relevanssi.content * 1 + relevanssi.comment * 0.75 +
    				relevanssi.tag * 0.75 + relevanssi.link * 0 +
    				relevanssi.author + relevanssi.category * 0.75 + relevanssi.excerpt +
    				relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn AS tf
    				FROM wp_relevanssi AS relevanssi  WHERE  relevanssi.term = 'web'   AND (relevanssi.doc IN (SELECT ID FROM wp_posts
    			WHERE (post_content LIKE '%web developer%' OR post_title LIKE '%web developer%' )
    			AND post_status IN ('publish','draft','private','pending','future','inherit')) OR relevanssi.doc IN (SELECT ID FROM wp_posts as p, wp_term_relationships as r, wp_term_taxonomy as s, wp_terms as t
    				WHERE r.term_taxonomy_id = s.term_taxonomy_id AND s.term_id = t.term_id AND p.ID = r.object_id
    				AND s.taxonomy IN ('category','people_position')
    				AND t.name LIKE '%web developer%' AND p.post_status IN ('publish','draft','private','pending','future','inherit')) OR relevanssi.doc IN (SELECT ID
    				FROM wp_posts AS p, wp_postmeta AS m
    				WHERE p.ID = m.post_id
    				AND (m.meta_key NOT LIKE '_%' OR m.meta_key = '_relevanssi_pdf_content')
    				AND m.meta_value LIKE '%web developer%'
    				AND p.post_status IN ('publish','draft','private','pending','future','inherit'))) ORDER BY tf DESC LIMIT 500

    However, when I search for just web developer, I get several smaller queries, like these two:

    
    SELECT DISTINCT(relevanssi.doc), relevanssi.*, relevanssi.title * 15 +
    				relevanssi.content * 1 + relevanssi.comment * 0.75 +
    				relevanssi.tag * 0.75 + relevanssi.link * 0 +
    				relevanssi.author + relevanssi.category * 0.75 + relevanssi.excerpt +
    				relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn AS tf
    				FROM wp_relevanssi AS relevanssi  WHERE  relevanssi.term = 'web'   ORDER BY tf DESC LIMIT 500
    
    SELECT DISTINCT(relevanssi.doc), relevanssi.*, relevanssi.title * 15 +
    				relevanssi.content * 1 + relevanssi.comment * 0.75 +
    				relevanssi.tag * 0.75 + relevanssi.link * 0 +
    				relevanssi.author + relevanssi.category * 0.75 + relevanssi.excerpt +
    				relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn AS tf
    				FROM wp_relevanssi AS relevanssi  WHERE  relevanssi.term = 'developer'   ORDER BY tf DESC LIMIT 500
    
    Plugin Author Mikko Saari

    (@msaari)

    Ok, so based on that Relevanssi is looking for the phrase in the people_position taxonomy. Is that the Job Type taxonomy? If not, that’s your problem, but if it is, I don’t know what’s up with that.

    You can check if those Relevanssi queries return any results; if they do but the search doesn’t, then the problem is somewhere after the query.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘“Exact phrase” search terms are not searching taxonomies’ is closed to new replies.