Boost Search on Taxonomy Pages

  • wpsolr
    Keymaster
    1 year, 6 months ago #31267

    “query_string” is used with boosts, and “query” without boosts.
    It could happen that fuzziness apply differently on both query types.
    I cannot help you more on that Elasticsearch feature.

    You could try with Solr, eventually.

    1 year, 6 months ago #31268

    Actually, we are transitioning from Solr, expecting all functionality would work with more enhancements.

    wpsolr
    Keymaster
    1 year, 6 months ago #31269

    WPSOLR 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.

    1 year, 6 months ago #31364

    Hi, 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 …

    wpsolr
    Keymaster
    1 year, 6 months ago #31367

    The weight are relative to each other: “2 and 1” should be similar in effect as “10 and 5”

    1 year, 6 months ago #31368

    Okay, 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.

    wpsolr
    Keymaster
    1 year, 6 months ago #31371

    How scoring is done is out of my reach, but all engines now use BM25.

    1 year, 6 months ago #31375

    Hi,
    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 );
      }
    }
    wpsolr
    Keymaster
    1 year, 6 months ago #31376

    You 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;
    }
    1 year, 6 months ago #31377

    Tried 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.php

    wpsolr
    Keymaster
    1 year, 6 months ago #31378

    Add:
    use wpsolr\core\classes\ui\WPSOLR_Query;

    Or remove the WPSOLR_Query type in the function parameters.

    1 year, 6 months ago #31381

    Like 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;
    }
    1 year, 6 months ago #31391

    As 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.

    wpsolr
    Keymaster
    1 year, 6 months ago #31397

    Relevancy 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.

    1 year, 5 months ago #31401

    I 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;
        }
    
Viewing 15 posts - 31 through 45 (of 49 total)

You must be logged in to reply to this topic.