pantheon-systems / solr-power

A WordPress plugin to connect to Pantheon's Apache Solr search infrastructure, or your own!
https://wordpress.org/plugins/solr-power/
GNU General Public License v2.0
126 stars 60 forks source link

Media Library search not working #537

Open bamadesigner opened 2 years ago

bamadesigner commented 2 years ago

Hi! When the Solr plugin is activated on our site, the Media Library search does not work in the "Grid" view. It does work for list view. This site is on a multisite network.

I don't have any more info at this time. I will be doing some digging on my end and will report back.

But am wondering if you are aware of this issue or have seen it on other environments.

Thanks!

bamadesigner commented 2 years ago

On the "grid" view for the Media Library in the admin (/wp-admin/upload.php?search=test), it is performating a JavaScript AJAX request to run the search.

The request goes to /wp-admin/admin-ajax.php. Here is the payload for a search of "test":

action: query-attachments post_id: 0 query[orderby]: date query[s]: test query[order]: DESC query[posts_per_page]: 80 query[paged]: 1

bamadesigner commented 2 years ago

The AJAX function being run is wp_ajax_query_attachments() which you can find here: https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/ajax-actions.php#L2951

bamadesigner commented 2 years ago

When I dig into the WP Query, here are the vars:

s: test
orderby: date
order: DESC
posts_per_page: 80
paged: 1
post_type: attachment
post_status: inherit,private
bamadesigner commented 2 years ago

If I comment out the following filter, the search works. So I'm digging into this function.

https://github.com/pantheon-systems/solr-power/blob/master/includes/class-solrpower-wp-query.php#L132

bamadesigner commented 2 years ago

Here is all the info being passed to $search = SolrPower_Api::get_instance()->query( $qry, $offset, $count, $fq, $sortby, $order, $fields, $extra ); at https://github.com/pantheon-systems/solr-power/blob/master/includes/class-solrpower-wp-query.php#L226

$qry: test AND(post_type:attachment)AND(post_status:inherit,private) $offset: 0 $count: 80 $fq: empty array $sortby: post_date $order: desc $fields: empty $extra: empty array

bamadesigner commented 2 years ago

I couldn't figure out the issue so for now I'm disabling Solr on the 'query-attachments' AJAX request.