Boost Search on Taxonomy Pages
- prakashreddy.imduriParticipant2 years ago #31268
Actually, we are transitioning from Solr, expecting all functionality would work with more enhancements.
wpsolrKeymaster2 years ago #31269WPSOLR features are the same with Elasticsearch and Solr, but the Elasticsearch decay scoring add-on
Perhaps the boosts with fuzzy works better for you with Solr.
prakashreddy.imduriParticipant1 year, 11 months ago #31364Hi, I want to boost title and then content, [only 2 boost fields in this case]
If I keep title as 5 and content as 3
or keep title as 50 and content as 10,
both means same results, as title is higher and content priority is less, or the number matters? or should I match their sum to 100 or 10 …prakashreddy.imduriParticipant1 year, 11 months ago #31368Okay, I sorted the results by relevancy, and added title with more priority than content, does this plugin work in this way : it will check for most words matching in different products, and ranks the product which has most matches in title and content ?
Bcos the results which I am seeing, has empty content, but still its ranks 1st, the second product has more matching keywords in title and description. Can you provide some info on this, or how to achieve this.prakashreddy.imduriParticipant1 year, 11 months ago #31375Hi,
Can we have something like this ? or any action/hook to achieve this?
We want to show fresh products in search homepage and, when user searches some query, we want to show results by relevancy.public function get_first_sort_by_default() { if ($_GET['s'] == '') { return 'publication_date_str_desc'; // sort by acf field, which is availaible in sort filter } else { return $this->get_option_value( true, __FUNCTION__, self::OPTION_SORTBY, self::OPTION_SORTBY_ITEM_DEFAULT_FIRST, WPSOLR_SearchSolariumClient::SORT_CODE_BY_RELEVANCY_DESC ); } }
wpsolrKeymaster1 year, 11 months ago #31376You can use an event for that:
add_filter( WPSOLR_Events::WPSOLR_FILTER_DEFAULT_SORT, 'wpsolr_filter_default_sort', 10, 2 ); /** * Apply specific default search on front * @param string $default_sort * @param WPSOLR_Query $wpsolr_query * @return string */ public function wpsolr_filter_default_sort( string $default_sort, WPSOLR_Query $wpsolr_query ) { return ($_GET['s'] === '') ? 'publication_date_str_desc' : WPSOLR_AbstractSearchClient::SORT_CODE_BY_RELEVANCY_DESC; }
prakashreddy.imduriParticipant1 year, 11 months ago #31377Tried this but getting error;
Fatal error: Uncaught TypeError: Argument 2 passed to wpsolr_filter_default_sort() must be an instance of WPSOLR_Query, instance of wpsolr\core\classes\ui\WPSOLR_Query given, called in /code/wp-includes/class-wp-hook.phpprakashreddy.imduriParticipant1 year, 11 months ago #31381Like this ?
use wpsolr\core\classes\engines\WPSOLR_AbstractSearchClient; use wpsolr\core\classes\WPSOLR_Events; add_filter( WPSOLR_Events::WPSOLR_FILTER_DEFAULT_SORT, 'wpsolr_filter_default_sort', 10, 2 ); /** * Apply specific default search on front * @param string $default_sort * @return string */ function wpsolr_filter_default_sort( string $default_sort ) { return ($_GET['s'] === '') ? 'publication_date_str_desc' : WPSOLR_AbstractSearchClient::SORT_CODE_BY_RELEVANCY_DESC; }
prakashreddy.imduriParticipant1 year, 11 months ago #31391As I need the products which has most matching words matching to query entered. Will relevancy alone is enough for this, or boosting is also needed?
Can you tell me how these both work together… what logic goes behind the relevancy.
Only keeping content in boost seems good, but issue is Its not bringing up products matching up titles first, If I add title and content both with same boost, the results aren’t good. It seems, its ignoring the order by matching more words in the product.
Main priority of results I want to give to products with more matching words to come at first, and then on the top of it, sorted by keywords matching in title.. Can you tell me , what setting to add for this in plugin.wpsolrKeymaster1 year, 11 months ago #31397Relevancy means sorting by highest scoring. And scoring is internal to Elasticsearch, to match a query to a document, based on BM25.
There are ways to implement your own scoring, inside Elasticsearch, with Java Elasticsearch plugins or Painless scripting. But this is out of WPSOLR’s reach.
prakashreddy.imduriParticipant1 year, 11 months ago #31401I have a test case, how can I achieve same with add action or filters? This code reference is taken from abstractsearchclient file. I want to catch the existing query word and change it based on some conditions. I modified it here to show you, I dont want to modify real code.
$word = 'old'; // example word to match ?s= // Get a chance to update the WPSOLR_Query $wpsolr_query = apply_filters( WPSOLR_Events::WPSOLR_FILTER_UPDATE_WPSOLR_QUERY, $wpsolr_query ); $this->set_wpsolr_query( $wpsolr_query ); // Create the query $this->query_select = $this->search_engine_client_create_query_select(); // Change search query if it matches this variable $word // test case if ( $_GET['s'] == 'test' ) { // Set the query keywords. $this->set_keywords( $word ); return; }
- This reply was modified 1 year, 11 months ago by prakashreddy.imduri.
You must be logged in to reply to this topic.