• Hi,

    I have recently noticed a “problem” with Relevanssi plugin, on all our websites.

    If I try to search for google.com as example, or any other domain name, I always get all posts back. Also, If I enable Relevanssi search for admin grid, I get the same results back (all of posts).

    Here is one Website as example which is still a DEV so I can play with it if you need me to test something. But the problem is on most of our currently maintained websites:
    http://dev.shoptrust.ch/zertifizierte-shoptrust-shops-finden/
    WP: v4.5.3
    Relevanssi plug-in: v3.5.3

    Appreciate your help
    Thx

    https://wordpress.org/plugins/relevanssi/

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

    (@msaari)

    Here’s my guess: your all posts have the word “com” in them, and you’re using OR search. Relevanssi replaces periods with spaces, so “google.com” becomes “google com”.

    Also, are you sure the site is actually using Relevanssi? The search term parameter on your site is “shop_search”, not “s”, and Relevanssi doesn’t know that.

    Plugin Author Mikko Saari

    (@msaari)

    This search is more likely powered by Relevanssi: http://dev.shoptrust.ch/?s=shoptrust

    And that doesn’t find every post if you search for “google.com”, only a couple of posts with the word “com” in them: http://dev.shoptrust.ch/?s=google.com

    Thread Starter cure85

    (@cure85)

    Hi Mikko,

    Thanks for the answers.

    Search is powered by relevanssi, I only use a custom parameter “shop_search” and a custom WP_Query which I pass to relevanssi to search only specific post types “webshop”. Docs: https://www.relevanssi.com/knowledge-base/relevanssi_do_query/

    You can also check this in Admin grid when you try to search for posts. This option can be enabled from Relevanssi settings. This can be tested in any WordPress installation.

    Yes I use AND search.

    My problem was in that I don’t get a result on TOP 1 position which has exactly “google.com” and then after to have every variation of words.
    This problem I have fixed by setting “orderby” parameter in WP_Query to value “relevassi”. It now works.

    If you can go here again: http://dev.shoptrust.ch/zertifizierte-shoptrust-shops-finden/

    1. Try searching “felbo” – you will get 1 result and it will be “felbo.ch”
    2. Try searching “felbo.ch” – You will get all the results which contain “ch” (which is every webshop in this project)

    Please check the current settings

    Plugin Author Mikko Saari

    (@msaari)

    Can you show me the code you’re using with relevanssi_do_query()?

    In any case, I can’t help much without seeing what’s going on inside the process – what kind of parameters Relevanssi gets, and what it passes on; whether the problem is in Relevanssi or the theme. That kind of debugging process is, however, too involved for this forum.

    Thread Starter cure85

    (@cure85)

    Hi Mikko,

    As I said before: This can be tested in any ADMIN SEARCH (Data grid -> right corner) on any theme, on any post or post type. see

    Just one note, Wp Core search works ok. If a I search for example ‘felbo.com’ I get 1 result back.

    Here is the code which I use on front only.

    <?php 
    
    $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
    $sort = filter_input(INPUT_GET, 'sort');
    $certificate_type = filter_input(INPUT_GET, 'certificate_type');
    $shop_search = filter_input(INPUT_GET, 'shop_search');
    
    $query_args = array(
    	'posts_per_page' 	=> 6,
    	'post_type' 		=> 'webshop',
    	'orderby' 		=> 'title',
    	'order'   		=> 'ASC',
    	'paged'			=> $paged,
    	'meta_query' => array()
    	);
    
    if($sort)
    {
    	$query_args['order'] = $sort;
    
    }else{
    
    	$query_args['orderby'] = 'relevanssi';
    	$query_args['order'] = '';
    }
    
    if($certificate_type)
    {
    	$query_args['meta_query'] = array(
    		array(
    			'key' => 'webshop_certificate',
    			'value' => $certificate_type,
    			'compare' => '='
    			)
    		);
    }
    
    $query = new WP_Query( $query_args );
    
    if(function_exists('relevanssi_do_query') && $shop_search)
    {
    	$query->query_vars['s'] = $shop_search;
    	$query->query_vars['posts_per_page'] = 6;
    	relevanssi_do_query($query);
    }
    ?>

    As I said this is acceptable for us now. Relevanssi gets us what we need exactly on 1st place and after he gets variations of [words].
    In other words he works like [OR] is enabled, but it is not. [AND] is enabled and [FALLBACK TO OR] is also disabled.

    Relevanssi configuration see

    Thanks for the help.
    Best regards

    Plugin Author Mikko Saari

    (@msaari)

    If I search for “google.com” on my site’s admin, I get 19 results, all of which include the word “google.com”, ie. the search works as it should. This has something to do with how your site is working.

    “relevanssi” is not a correct parameter for “orderby”, it should be “relevance”. I think “order” should default to “DESC”, but it’s better to be explicit about it.

    You may also try setting the “operator” parameter explicitly to “AND”.

    Thread Starter cure85

    (@cure85)

    Hi Mikko,

    I have changed the parameter to ‘relevance’.
    And set operator: $query->query_vars['operator'] = 'and';

    with no luck.

    I’ll try to see if something else is affecting my search results, as you say.

    In any case
    Thank you for the help, and fast response
    Best regards

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Search returns all posts when searched for domain name ex. (google.com)’ is closed to new replies.