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/api/routes/class-query-plugins.php

    r10115 r10117  
    6666        }
    6767
    68         // Temporary hacky block search
    69         $block_search = trim( strtolower( $request->get_param( 'block' ) ) );
     68        // Block Directory searches
     69        $block_search = $request->get_param( 'block' );
    7070        if ( $block_search ) {
    71             $meta_query = array(
    72                 'relation' => 'AND',
    73                 array(
    74                     'key' => 'block_files',
    75                     'compare' => 'EXISTS',
    76                 ),
    77                 array(
    78                     'relation' => 'OR',
    79                     array(
    80                         'key' => 'block_name',
    81                         'value' => '^' . preg_quote( $block_search ),
    82                         'compare' => 'RLIKE',
    83                     ),
    84                     array(
    85                         'key' => 'block_name',
    86                         'value' => '/' . $block_search, // search following the slash
    87                         'compare' => 'LIKE',
    88                     ),
    89                     array(
    90                         'key' => 'block_title',
    91                         'value' => $block_search, // search in title
    92                         'compare' => 'LIKE',
    93                     ),
    94                     array(
    95                         'key' => 'header_name',
    96                         'value' => $block_search, // search in plugin title
    97                         'compare' => 'LIKE',
    98                     ),
    99                 )
    100             );
    101 
    102             // Limit the search to the Block section
    103             $query[ 'meta_query' ] = $meta_query;
    104             $query[ 'tax_query' ] = array(
    105                 array(
    106                     'taxonomy' => 'plugin_section',
    107                     'field' => 'slug',
    108                     'terms' => 'block',
    109                 )
    110             );
     71            $query['s'] = $block_search;
     72            $query['block_search'] = true;
    11173        }
    11274
Note: See TracChangeset for help on using the changeset viewer.