{"id":17091870,"date":"2023-10-01T19:24:21","date_gmt":"2023-10-01T19:24:21","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/need-help-fine-tuning-the-did-you-mean-feature\/"},"modified":"2023-10-01T19:30:54","modified_gmt":"2023-10-01T19:30:54","slug":"need-help-fine-tuning-the-did-you-mean-feature","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/need-help-fine-tuning-the-did-you-mean-feature\/","title":{"rendered":"Need help fine tuning the Did you mean feature"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hi,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks for this great plugin. I&#8217;ve only now realized that it has the &#8220;Did you mean?&#8221; feature, and I&#8217;m trying to implement it on a free version (hobby site). Mine is a pronunciation dictionary, and as is common for online dictionaries, I&#8217;ve set Relevanssi to (1) redirect to the word when there&#8217;s (only one) perfect match; (2) list alternative words when there are more than one match; and (3) 404 with &#8220;Your search didn&#8217;t find anything&#8221; when there&#8217;s no match at all. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;ve managed to add the snippet to create the shortcode for the Did You Mean functionality, but I&#8217;m having 2 issues. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First, I&#8217;m having a hard time adding the filter to change the number of hits a successful search needs to have to be considered as alternative. Currently, only misspelled searches for words that would return 3 or more hits are properly showing alternatives. So I&#8217;m trying to add the filter to actually reduce that number, instead of increasing it, as having only 1 hit would be the case with 95% of my posts. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter( 'relevanssi_get_words_having', function() { return 1; } );\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">I tried adding it right before and right after the shortcode snippet in the <code>functions.php<\/code>, but it changed nothing. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do I also need to change the line that invokes the shortcode in the search results<code>index.php<\/code> file? Sorry if this is too basic, but though familiar with coding to add snippets, I&#8217;m not a developer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The second issue is that, for those cases where the DYM is successfully added to the results page, I&#8217;m seeing it return twice the same line, with the same URL. That URL is the search results page with all the hits for the successful term. So if I search for <code>tho<\/code> it give me back:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Voc\u00ea quis dizer: to?\n\nVoc\u00ea quis dizer: to?<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Where <code>to<\/code> is actually the URL where you find matches for the term <code>to<\/code> as well as 5 expressions such as <code>have to<\/code>, <code>next to<\/code> etc. Ideally, I&#8217;d have 6 lines, each pointing to the end URL of each of these terms and phrases.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you in advance for your time and any help will be much welcome.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">EDIT: I should add that I&#8217;ve set search logging a few years back, so I have enough terms already logged. Example of searches that are not returning:<\/p>\n\n\n\n<ul>\n<li>Query # Hits Clicks<\/li>\n\n\n\n<li>that\u00a0<a href=\"https:\/\/dicio.eauladeingles.com\/?s=that\"><\/a>24 1 &#8211;<\/li>\n\n\n\n<li>where\u00a0<a href=\"https:\/\/dicio.eauladeingles.com\/?s=where\"><\/a>20 1 &#8211;<\/li>\n\n\n\n<li>there\u00a0<a href=\"https:\/\/dicio.eauladeingles.com\/?s=there\"><\/a>20 1 &#8211;<\/li>\n\n\n\n<li>this\u00a0<a href=\"https:\/\/dicio.eauladeingles.com\/?s=this\"><\/a>20 1 &#8211;<\/li>\n\n\n\n<li>with\u00a0<a href=\"https:\/\/dicio.eauladeingles.com\/?s=with\"><\/a>20 2 &#8211;<\/li>\n<\/ul>\n","protected":false},"template":"","class_list":["post-17091870","topic","type-topic","status-publish","hentry","topic-tag-filter","topic-tag-shortcode"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/17091870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/17091870\/revisions"}],"predecessor-version":[{"id":17091878,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/17091870\/revisions\/17091878"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=17091870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}