geerlingguy / jeffgeerling-com

Drupal Codebase for JeffGeerling.com
https://www.jeffgeerling.com
GNU General Public License v2.0
40 stars 2 forks source link

Add Hosted Apache Solr search integration #54

Closed geerlingguy closed 4 years ago

geerlingguy commented 4 years ago

I currently use Hosted Apache Solr to host a Drupal 7 search index for my site. I need to create a new index for Drupal 8 so I can start using that with Search API and Search API Solr, and recreate the search functionality on JeffGeerling.com. Note that this issue is a prerequisite to #2.

Details for subscription ID 1181 from Hosted Apache Solr:

geerlingguy commented 4 years ago

To get the search excerpts to display, I went to the search index 'Processors' and enabled the 'Highlight' processor (thanks to some advice from this blog post: How to highlight search results in Search API Solr View in Drupal 8).

During the live stream, we got titles to appear, but couldn't get the body text to appear:

Screen Shot 2020-04-28 at 11 59 53 AM

After enabling the Highlight processor:

Screen Shot 2020-04-28 at 12 00 26 PM

Now, on to theming!

geerlingguy commented 4 years ago

It seems like the disconnect on the live stream came from config not having a password stored; I checked after exporting config again (and re-saving the password), and it showed the password in plain text, e.g.:

@@ -44,7 +44,7 @@ backend_config:
     finalize_timeout: 30
     commit_within: 1000
     username: 'username_here'
-    password: ''
+    password: password_here
     solr_version: ''
     http_method: AUTO
     jmx: false

So I opened an issue on Drupal.org Prevent password from being stored in configuration, and we'll see what other people say. I want to keep this codebase open source, but there's no way I can do that if there's a plaintext password that has to be in the exported config so Solr search works!

geerlingguy commented 4 years ago

Ha, I'm working on implementing facets for the search page, and I ran into this old gem on my own YouTube channel: https://www.youtube.com/watch?v=J8Rt6HSzrqY

geerlingguy commented 4 years ago

Haha, how deep the rabbit hole goes; another article I found was Faceted Search in Drupal 8: Using Search API Solr and Facets... and was also by me :P

geerlingguy commented 4 years ago

Search is mostly working now, though I'm not sure why Facets is returning some weird data, should have many more articles from 2016 and beyond here...

Screen Shot 2020-04-28 at 1 27 34 PM
geerlingguy commented 4 years ago

I got search working well; a few notes:

  1. I had to select Body » Processed text and Comments » Number of comments, and I also added boost to the Title field by setting it to 'Fulltext'
  2. For the facets, I had to spend about 20 minutes tweaking all the ordering and display settings so they worked in a manner that felt 'usable' to me (e.g. short by year, descending, don't show the option for '0' comments, etc.)

Search API Solr, Facets, and Search API Views are definitely an area of Drupal where it's more 'art' than 'science', though. But in the end, the search results are working slightly better than what they were in Drupal 7, so I'm happy :)

I also use one exposed form block for both the sitewide footer search form and the search page search form, so theming was very slightly simplified there :)