• Resolved alpakal

    (@alpakal)


    Hi,

    I’m trying to integrate elasticsearch into our website, and to replace the default wordpress search function with elasticsearch. We are using a plugin called Elasticpress;

    https://github.com/10up/ElasticPress#wp_query-and-the-elasticpress-query-integration

    It has ready functionality for bbpress and woocommerce and I’d very much like to add elasticsearch functionality to WP Advert in production because I know after a short period of time, wordpress search will be bogged down and take minutes to complete. I’ll much appreciate if you can show me the way to replace the search function for WP Advert to something like;

    new WP_Query( array(
    ‘s’ => ‘term search phrase’,
    ‘search_fields’ => array(
    ‘post_title’,
    ‘post_content’,
    ‘post_excerpt’,
    ‘taxonomies’ => array( ‘category’, ‘post_tag’ ),
    ),
    ) );

    I have taken this example from the Elasticpress plugin documentation on Github. The “s” term adds the functionality for elasticsearch, while the Elasticpress function is in use. But I don’t know where to hook this into. Thanks very much for your help, really appreciate it!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi, hmmm i am not really familiar with the ElasticSearch, but if i understand documentation correctly then all you need to do in order to have the queries use ElasticSearch is add ep_integrate param to WPAdverts WP_QUERY.

    To do that you can add following code to your theme functions.php

    
    add_filter("adverts_list_query", "ep_adverts_list_query");
    function ep_adverts_list_query( $params ) {
        $params["ep_integrate"] = true;
        return $params;
    }
    

    This should enable EP search on all pages with [adverts_list] shortcode.

    Thread Starter alpakal

    (@alpakal)

    Hey,

    An elegant solution. Thanks a bunch. I’ll test it out as soon as I set up an Elastic server and notify you of the result. Maybe other people who’d like to setup such a search functionality would benefit from this. Cheers,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Elasticsearch integration’ is closed to new replies.