Making WordPress.org


Ignore:
Timestamp:
08/05/2020 01:49:48 AM (5 years ago)
Author:
dd32
Message:

Plugin Directory: Search: Transform Block Directory block searches over to ElasticSearch.

Block Searches might be less reliable today while this change is finalised, a few other index alterations are needed for all current blocks to be properly indexed.
Some changes to the boosting phrases will also be needed most likely once this is finalised and we can do some proper testing.

File:
1 edited

Legend:

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

    r10115 r10117  
    430430        }
    431431
     432        // Block Search.
     433        if ( !empty( $query->query['block_search'] ) ) {
     434            $es_wp_query_args['block_search'] = $query->query['block_search'];
     435
     436            // Limit to the Block Tax.
     437            $es_wp_query_args['filters'][] = array(
     438                'term' => array(
     439                    'taxonomy.plugin_section.name' => array(
     440                        'value' => 'block'
     441                    )
     442                )
     443            );
     444        }
     445
    432446        $es_wp_query_args['locale'] = $query->get( 'locale' ) ?: get_locale();
    433447
     
    763777        }
    764778
     779        $is_block_search = ! empty( $args['block_search'] );
     780
    765781        if ( $args['locale'] && $args['locale'] !== 'en' && substr( $args['locale'], 0, 3 ) !== 'en_' ) {
    766782            $locale = $args['locale'];
     
    788804                'taxonomy.plugin_tags.name',
    789805            );
     806            if ( $is_block_search ) {
     807                $boost_phrase_fields[] = 'block_title_' . $locale;
     808                $boost_phrase_fields[] = 'block_title_en^' . $en_boost;
     809            }
    790810            $boost_ngram_fields   = array(
    791811                'title_' . $locale . '.ngram',
     
    797817                'slug_text',
    798818            );
     819            if ( $is_block_search ) {
     820                $boost_title_fields[] = 'block_title_' . $locale;
     821                $boost_title_fields[] = 'block_title_en^' . $en_boost;
     822                $boost_title_fields[] = 'block_name';
     823            }
    799824            $boost_content_fields = array(
    800825                'excerpt_' . $locale,
     
    814839                'taxonomy.plugin_tags.name',
    815840            );
     841            if ( $is_block_search ) {
     842                $boost_phrase_fields[] = 'block_title_en';
     843            }
    816844            $boost_ngram_fields   = array(
    817845                'title_en.ngram',
     
    821849                'slug_text',
    822850            );
     851            if ( $is_block_search ) {
     852                $boost_title_fields[] = 'block_title_en';
     853                $boost_title_fields[] = 'block_name';
     854            }
    823855            $boost_content_fields = array(
    824856                'excerpt_en',
Note: See TracChangeset for help on using the changeset viewer.