Boost Search on Taxonomy Pages
- wpsolrKeymaster1 year, 11 months ago #31404
Something like that should work:
<?php use wpsolr\core\classes\ui\WPSOLR_Query; use wpsolr\core\classes\WPSOLR_Events; add_action( WPSOLR_Events::WPSOLR_FILTER_UPDATE_WPSOLR_QUERY, 'update_keywords', 10, 1 ); /** * * Update the WPSOLR keywords based on some conditions. * * @param WPSOLR_Query $wpsolr_query * * @return WPSOLR_Query */ function update_keywords( WPSOLR_Query $wpsolr_query ) { $current_keywords = $wpsolr_query->get_wpsolr_query(); /** * Change keywords based on your conditions here */ if ( 'test' === $current_keywords ) { $wpsolr_query->set_wpsolr_query( 'trial' ); } return $wpsolr_query; }
prakashreddy.imduriParticipant1 year, 11 months ago #31405Okay, this worked.
prakashreddy.imduriParticipant1 year, 11 months ago #31437Can we pass like this too : As we don’t want to miss results related to test, Can we have results of test and trial both, instead of mapping it to trial only.
if ( 'test' === $current_keywords ) { $wpsolr_query->set_wpsolr_query( 'trial or test' ); }
wpsolrKeymaster1 year, 11 months ago #31439It should work with ‘trial OR test’
Check out Elasticsearch guilde for query_string
You must be logged in to reply to this topic.