• Resolved mikehermary

    (@mikehermary)


    Hello,

    We have set the weights on the defined search areas like this in the admin panel:

    • Content: 100
    • Tags: 80
    • Titles: 60
    • Categories: 40
    • Comments: 0.75

    A post with an exact match in a tag is not being displayed first in the search results. For example, BigFoot & Co Ltd, which has a tag defined as “car wash” is not displaying first, whereas a post with the tags “auto” and “car”, is displaying first.

    Another post, Speedy Wash Laundromat, which does not include “car” or “wash” in its title, tags, or content, is displaying before BigFoot & Co Ltd in the results.

    As you can see, this is unexpected. We have tried setting Keyword Matching to “partial words” instead of “Partial words if not hits for whole words”, but the results become even more problematic as “car” is found in the title and those results are returned first. In this case, it seems the title weight is overriding the content and tag weights, which are higher, as detailed above.

    We do not have any filters or hooks in our functions file to override these settings, though we are hoping to apply extra boosts for exact match content and tags using the exact boost filter.

    Any help is greatly appreciated.

    Cheers,

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

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

    (@msaari)

    When debugging search weights, it’s best to use Relevanssi admin search (Dashboard > Admin search), as it shows the exact weights Relevanssi has calculated. That will give you a better idea why the posts are ranked the way they are.

    In this case it would be helpful to know how big a difference we’re talking about here – are the first posts beating the BigFoot post with a small margin or a big margin. What do the results look like in the admin search?

    Looking at individual words, the BigFoot post ranks really low for “car” and last for “wash”, so it can’t rank at the top for “car wash”. But without seeing the exact scores, it’s very hard to say anything more concrete than that.

    Thread Starter mikehermary

    (@mikehermary)

    Hello,

    Thanks for the reply.

    Big Foot & Co scores 188.57 and Speedy Laundromat scores 3771.32, so there is a big difference.

    Cheers,

    Plugin Author Mikko Saari

    (@msaari)

    What happens if you change the tag weight to, say, 4000?

    If you want the exact tag matches to rank first, it’s probably best to create a filter that does specifically that instead of adjusting the weights.

    Thread Starter mikehermary

    (@mikehermary)

    Hello,

    I have tried changing the tag weight to 3600 and the content weight to 4000, but posts without any tags are still displaying first in the search results. Titles are still using the weight of 60.

    A example result of “Redline Truck ‘N’ Trailer Services” is displaying first in the results when searching for “truck wash”. Its title contains “truck”, but there are no tags attached to this post and no text contained in its post content block.

    Another example results, “BigFoot & Co Ltd” is displaying fourth in the results when searching for “truck wash”. It has the following tags: “car wash” and “truck wash”, but no text contained in its post content block.

    Any suggestions? Would using a filter be the better option?

    Cheers,

    Plugin Author Mikko Saari

    (@msaari)

    How does changing the weights affect the relevance scores? Do they change? Are the tag-only matches still scoring low, or do the title matches also get a boost? It’s much easier for me to understand this problem if I can see the exact scores.

    This should work with just the weights, but something’s off here, I just can’t tell exactly what just with this information alone.

    Thread Starter mikehermary

    (@mikehermary)

    Hello,

    The scores remained the same no matter the weights. See the query and results below.

    Query variables:
    post_types: gd_place
    s: car wash
    relevanssi_admin_search: 1
    operator: OR
    posts_per_page: -1

    4000 for content, 3600 for tags, 60 for titles

    Ron’s Gas & Wash gd_place (Edit gd_place)
    Score: 3834.17

    Speedy Wash Laundromat gd_place (Edit gd_place)
    Score: 3771.32

    BigFoot & Co Ltd gd_place (Edit gd_place)
    Score: 188.57

    100 for content, 80 for tags, 60 for titles

    Ron’s Gas & Wash gd_place (Edit gd_place)
    Score: 3834.17

    Speedy Wash Laundromat gd_place (Edit gd_place)
    Score: 3771.32

    BigFoot & Co Ltd gd_place (Edit gd_place)
    Score: 188.57

    Ron’s Gas & Wash place listing has no content and the following tags: auto, automotive, and car.

    BigFoot & Co Ltd place listing has no content and the following applicable tags: car wash and truck wash.

    Adding “Wash” to the title of BigFoot & Co Ltd boosts it to number one in the results.

    Removing “Wash” from the Ron’s Gas & Wash title lowers its ranking in the search results.

    It seems titles are receiving the most weight, no matter what the scores are set to in the admin panel.

    Cheers,

    Thread Starter mikehermary

    (@mikehermary)

    Hello Mikko,

    Just checking to see if you had a chance to review my last reply with additional details.

    Thanks for all of your assistance so far.

    Cheers,

    Plugin Author Mikko Saari

    (@msaari)

    Sorry, for some reason I didn’t get any email notification from your reply, and I rely on the notifications to follow topics.

    If you set the title weight to 0, do all the weights drop to 0? Looks like the tags aren’t really counted at all.

    Can you please check the MySQL query Relevanssi is doing with Query Monitor (instructions here if you’re unfamiliar with it: https://www.relevanssi.com/knowledge-base/debugging-with-query-monitor/)?

    Thread Starter mikehermary

    (@mikehermary)

    Hello Mikko,

    Thanks for the reply.

    I have dropped the weight for the titles to 0 and left everything as is. When I perform an admin search for “car wash”, the BigFoot & Co Ltd post moves into result number one.

    Here are the Query Monitor queries:

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

    (@msaari)

    Those scores are still very low considering the tag weight is 3600. Based on all the data, the only explanation I can come up with is that those tags are not actually tags at all, but instead some other taxonomy. Is this possible?

    Thread Starter mikehermary

    (@mikehermary)

    Hello Mikko,

    Here are the admin URLs for GeoDirectory Place CPT tags and core WordPress. The GD place tags seem to use the same taxonomy structure as core, so I am not sure this would be causing the issues.

    • /wp-admin/edit-tags.php?taxonomy=gd_place_tags&post_type=gd_place
    • /wp-admin/edit-tags.php?taxonomy=post_tag

    Are you aware of any compatibility issues between your plugin and GeoDirectory?

    Cheers,

    Plugin Author Mikko Saari

    (@msaari)

    You should be adding weight to gd_place_tags, if those are the tags you’re using – you’ve now added all that weight to the post_tag taxonomy, but it’s a different taxonomy and adding weight there doesn’t affect the gd_place_tags at all.

    Adding weights for individual taxonomies from the settings page is a Premium feature, but you can do this:

    add_filter( 'relevanssi_match', 'rlv_boost_gd_place_tags' );
    function rlv_boost_gd_place_tags( $match ) {
    	if ( has_term( '', 'gb_place_tags', $match->doc ) ) {
    		$match->weight *= 100;
    	}
    	return $match;
    }

    Does this fix the problem?

    Thread Starter mikehermary

    (@mikehermary)

    Hello Mikko,

    Thanks for the code snippet. I really appreciate it.

    It has helped with our issue, but we are still working on adjusting weights and code in order to provide the best search results for our client’s site.

    Cheers,

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Issues with search area weights’ is closed to new replies.