Making WordPress.org

Changeset 3597


Ignore:
Timestamp:
06/26/2016 03:02:20 PM (10 years ago)
Author:
tellyworth
Message:

Plugin directory search: further tweaks for search quality - notably, better handling of close name matches.

See #1692

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/jetpack-search.php

    r3591 r3597  
    281281                $locale = get_locale();
    282282                if ( $locale && $locale !== 'en' && $locale !== 'en_US' ) {
    283                         $es_wp_query_args['query_fields'] = array( "title_{$locale}^2", 'title_en^0.5', "content_{$locale}^2", 'content_en^0.5', "excerpt_{$locale}", 'excerpt_en', 'author', 'tag', 'category', 'slug_ngram', 'contributors' );
    284                         $es_wp_query_args['boost_fields'] = array( "title_{$locale}", 'title_en' );
     283                        $es_wp_query_args['query_fields'] = array( "title_{$locale}_ngram^4", 'title_en_ngram^0.5', "content_{$locale}_ngram^2", 'content_en_ngram^0.5', "excerpt_{$locale}_ngram", 'excerpt_en_ngram', 'author', 'tag', 'category', 'slug_ngram', 'contributors' );
    285284                } else {
    286                         $es_wp_query_args['query_fields'] = array( 'title_en^2', 'content_en', 'excerpt_en', 'author', 'tag', 'category', 'slug_ngram', 'contributors' );
    287                         $es_wp_query_args['boost_fields'] = array( 'title_en' );
     285                        $es_wp_query_args['query_fields'] = array( 'title_en_ngram^4', 'content_en_ngram^2', 'excerpt_en_ngram', 'author', 'tag', 'category', 'slug_ngram', 'contributors' );
    288286                }
    289287
     
    615613                                                        ),
    616614                                                ),
    617                                                 array(
    618                                                         'multi_match' => array(
    619                                                                 'query'  => $args['query'],
    620                                                                 'fields' => $args['boost_fields'],
    621                                                                 'type'  => 'phrase',
    622                                                                 'analyzer' => $analyzer,
    623                                                                 'boost' => 2,
    624                                                         ),
    625                                                 ),
    626615                                        ),
    627616                                ),
     
    720709        public static function score_query_by_recency( $query ) {
    721710                //Newer content gets weighted slightly higher
    722                 $date_scale = '720d';
     711                $date_scale = '360d';
    723712                $date_offset = '180d';
    724713                $date_decay = 0.7;
     
    750739                                                                'field_value_factor' => array(
    751740                                                                        'field' => 'meta.active_installs.long',
    752                                                                         'factor' => 0.8,
     741                                                                        'factor' => 2,
    753742                                                                        'modifier' => 'log2p',
    754743                                                                ),
     
    757746                                                                'field_value_factor' => array(
    758747                                                                        'field' => 'support_threads_resolved',
    759                                                                         'factor' => 0.8,
     748                                                                        'factor' => 1,
    760749                                                                        'modifier' => 'log2p',
    761750                                                                ),
Note: See TracChangeset for help on using the changeset viewer.