Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #1415158

    Hi guys,
    I have raised this as a ticket with Relevanssi but wondered if there has been an update from Enfold’s end.
    Previous posts have not provided a valid solution.

    When Relevanssi is installed the Ajax search results that appear from the Enfold Search bar is set to all results meaning you get an extremely long load time for ajax results and a list as long as the entire page!
    If you turn on Throttling in Relevanssi settings it limits this to 500 entries but also limits the full search results page to 500 entries.

    If I add the following function it limits the Ajax search to 5 entries BUT also limits the full search results page to 5 entries. This is obviously not great for users and in solving the ajax issue it causes another problem!
    add_filter( 'pre_option_relevanssi_throttle_limit', function( $limit ) { return 5; } );

    Is there a way to limit just the Ajax search results to 5 rather than globally adjusting the Relevanssi search to 5.

    I want to limit Ajax instant searches to between 5 – 50 results and let the actual search results page display all or use the standard 500 throttle limit.

    #1415171

    Hey Thomas,

    I did not dig deeper in it, but when the full search result page does not use ajax you could try:

    
    if( wp_doing_ajax() )
    {
        add_filter( 'pre_option_relevanssi_throttle_limit', function( $limit ) { return 5; } );
    }
    

    Best regards,
    Günter

    #1415172

    Hi Gunter,

    That works. But the theme developer is suggesting a better way to do this.
    https://wordpress.org/support/topic/limit-ajax-search-to-5-posts/#post-16938764

    Although this works
    It means the Ajax search results are a lot less accurate so it isnt perfect but at least it gives much better control over the ajax and increases the speed.
    Setting this to 25-50 seems to improve the search accuracy on the site I am using it on.

    • This reply was modified 8 months, 2 weeks ago by thinkjarvis.
    • This reply was modified 8 months, 2 weeks ago by thinkjarvis.
    • This reply was modified 8 months, 2 weeks ago by thinkjarvis.
    #1415178

    Hi,

    Have a look into enfold\config-relevanssi\class-avia-relevanssi.php

    Around line 170 you find:

    
    			$tempquery->query_vars = $search_parameters;
    			relevanssi_do_query( $tempquery );
    

    Try the following:

    
    			$tempquery->query_vars = $search_parameters;
    			$tempquery->set( 'posts_per_page', 5 );
    			relevanssi_do_query( $tempquery );
    

    Best regards,
    Günter

    #1415180

    Hi Gunter,

    Sorry crossed wires here.
    I have updated my response to your original post.
    The second fix enfold\config-relevanssi\class-avia-relevanssi.php seems to work

    However both of your suggestions cause the ajax search to have different results to the search page.
    BUT
    The longer and more specific the search term – The less this is a problem.

    I have changed the value to 25 in class-avia-relevanssi.php and also used the css below to control the size of the dropdown:

    .ajax_search_response {
        max-height: 300px;
        overflow-y: scroll;
    }
    #1415182

    Hi,

    If this is a solution I can add a filter for next release.
    Just let me know.

    Best regards,
    Günter

    #1415184

    Hi Gunter,

    The filter works as expected when the standard search layout is used – but has thrown another problem.
    Please add the filter it is a good solution.

    I have customised the searchform.php file adding:
    <input type=”hidden” name=”post_type” value=”product”>
    into the <form> tags.

    This is causing the search to show different results to the ajax search.
    Any idea how I can bring the two into alignment?

    The search query changes from
    /?s=samsung
    to
    /?s=samsung&post_type=product

    #1415188

    I’ve figured out what it is doing.
    I am happy with the results please add the filter.

    #1415189

    Hi,

    Filter will be in 5.6.6:

    https://github.com/KriesiMedia/enfold-library/blob/master/actions%20and%20filters/Compatibility%20Plugins/Relevanssi/avf_relevanssi_ajax_search.php

    searchform.php

    This is the default that a form collects all input on submit.

    Try this (adding the disabled attribute):

    https://stackoverflow.com/questions/3008035/stop-an-input-field-in-a-form-from-being-submitted/#answer-3008066

    Best regards,
    Günter

    #1415203

    Thanks Gunter,

    The main reason for using Relevanssi for me was a speed improvement (where the SKU is included in the search). Relevanssi creates its own search index which helps keep the lookups quick.

    I now have a couple of extremely large woocommerce sites with Enfold that are all running extremely smoothly so Relevanssi is a natural progression to improve search.

    #1415310

    Hi,

    Thanks for providing insight into relevanssi and that it helps on large sites and works well with Enfold.

    Have a great day.

    Best regards,
    Günter

    #1415311

    No problem,

    Thanks again for finding a solution to this – really happy with this. I used to use an old script for adding SKUs to the default search however it now uses depreciated code (and it was a slow query) so this is a much better solution.

    Can the documentation be updated with the new snippet/filter once 5.6.6 gets released?

    There are a few highly ranking Enfold forum entries with the incorrect solution on them. If they are still open to comment I’ll add the new solution to the posts once 5.6.6 is released.

    #1415323

    Hi,

    I tagged Yigit for this topic. He will come back to you in case he needs more info for the docu.

    We appreciate your help.

    Best regards,
    Günter

    #1415328

    Hey Thomas,

    I’ve added a new section to our documentation with the new filter. Please see the link in the private content field.

    Regards,
    Yigit

    #1415330

    Thanks Yigit
    See comments below

    #1415333

    Hey,

    Thanks!

    Regards,
    Yigit

Viewing 16 posts - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.