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

Anyone experience issues with a custom schema.xml file not being used on pantheon? #490

Closed vinny-smooches closed 3 years ago

vinny-smooches commented 3 years ago

This is a bit of an odd issue, I am working with the support team at Pantheon trying to debug why a custom schema.xml file uploaded to the uploads\solr-for-wordpress-on-pantheon\ directory is not being used after it has been successfully reposted and the site re-indexed. I have tried all environments, DEV, TEST, and LIVE, the results are the same across the board. It feels like the default schema.xml file is the only one being used during indexing.

My updates to the schema file are not complex, I am simply adding a couple of additional fields to the schema.xml for search. Namely the post_author and a custom taxonomy. I followed the instructions in the readme for adding the post_author. And added a copyField of a custom taxonomy to the "text" field. I have tested multiple versions of the schema.xml file, to the point where the only addition I made was the post_author 1 to 1 with the readme.

No matter what I put in the schema, or how I repost this schema.xml file, whether it's using the plugins admin screen or the WP CLI, I get a "Success: Schema reposted: Schema Upload Success: 200", message. And a successful reindexing, but the search results do match what I am expecting to see. In this case, if I search with an author's name, that I know is in the system, I get 0 results.

The conclusion I keep coming back to is Pantheons SOLR server seems to only use the default schema.xml file. I am not doing anything else in my functions file that would modify the query. Additionally, I have a local version of this setup, and I am using an almost identical version of Apache SOLR running locally, and indexing with my custom schema.xml file. This all works properly, my search results return as I expect them to. Searching by an author name returns posts by that author. Searches with the custom taxonomy terms return results as well. Since it's my local, I have access to the 3.6 SOLR admin area, and I can see all of the indexed data, and it looks correct to me.

It's baffling to me, and with the limited access we are granted to the Pantheon SOLR instances, I can't debug this. Hopefully, someone in here or on the pantheon support team can help me chase this down. I am running out of ideas.

vinny-smooches commented 3 years ago

So for posterity's sake, with the help of Carl on the pantheon helpdesk side, he deduced that since we are using a composer install method for WP, which is moving around the directories, namely the wp-content folder so it is no longer in the wp directory. This appears to be the culprit here, the solr-power plugin doesn't actually look at what WP is using as its content directory, but rather looks in the default wp/wp-content/uploads/solr-for-wordpress-on-pantheonfor the schema file no matter what.

This leads to the default schema being loaded since there is no "custom schema" found. The problem I have with this scenario is that the plugin should mention, what schema file it's loading in addition to whether or not it was successful. something like:

Success: Loaded Default Schema or Success: Loaded Custom Schema.

Based on that, it would make it a bit easier for a dev who is having issues posting their schema file to understand if their custom file is ever actually making it to the Solr server.

What needed to be done to fix the issue: Recreate the path to the schema.xml file in the wp directory, and commit that to the pantheon repo, however you need to.

wp/wp-content/uploads/solr-for-wordpress-on-pantheon/schema.xml

I am doing this in our build script through GitHub actions and moving a source-controlled version of our custom schema.xml file into position before the action commits and pushes to Pantheon. Repost the schema, after that deploys then re-index. Seems to work perfectly now.

Thanks for the great plugin, and I hope this helps anyone else who runs into an issue with custom schema's and composer installed versions of WP.

danielbachhuber commented 3 years ago

Thanks for documenting the fix, @vinny-smooches ! I'm incorporating the expected path with #492