The Automated Librarian: Part 5 – Fine-Tuning the UI with Facets and Search API
February 25, 2026In Part 4 of this series, I gave my library a "brain" by using local AI to generate summaries and clean up metadata. I even showcased the basic Search API View in action—a fast, full-text search that finally made 20 years of PDFs accessible.
But as I spent more time in the EBook library lab, I realized that search is a two-way street. Sometimes I know exactly what I'm looking for (Search). Other times, I want the library to tell me what it has (Discovery).
Today, I'm moving beyond the search box to build a professional discovery interface using Facets.
The Friction of a Single Search Box
The video in Part 4 showed a functional search, but it required me to do all the work. If I wanted to find every Drupal book published in 2023, I had to type it out. If I wanted to see only the books categorized as "Software," I had to hope I spelled the category correctly.
To make the Automated Librarian not only useful, but pleasant to use, I needed to provide a roadmap. In Drupal 11, that roadmap is built with the Facets module.
Step 1: Connecting the Dots (Search API & Facets)
Because my View is already powered by a Search API index, I've already done the hard part. Facets don't query the database; they query the index directly.
I enabled the Facets module and went to work on the fields I refined in the last post:
- Category: To separate "Networking" from "Web Development."
- Publish Year: To distinguish between a legacy Drupal 7 guide and a modern Drupal 11 manual
- Author: To find every title by a specific technical expert.
Note: Facets 3 now recommends using the Facets Exposed Filters submodule. I am using this method for creating and exposing facets. While creating facet blocks is still supported for backwards compatibility, integrating them directly as exposed filters keeps the configuration tightly coupled with the View.
Step 2: The "AJAX" Magic
There is nothing more frustrating than a page that refreshes every time you click a filter. To keep the experience "pleasing", I enabled AJAX on the View. Now, when I click a "Category" facet, the results update instantly.
This creates a "shopping" experience for knowledge. I click, the list narrows, I click again, and there it is—the exact PDF I needed.
Step 3: Configuring the Facet Display
A list of 50 categories is a mess. To keep the UI clean, I implemented a few key Facet settings:
- Soft Limits: Only show the top 10 categories, with a "Show More" link.
- Hide Empty Facets: If a search result doesn't have any "Linux" books, the "Linux" filter disappears. This prevents the "No results found" frustration.
- Count Display: Showing the number of items next to each filter (e.g., PHP (12)) gives me immediate context on how deep that particular hole goes.
The Transformation: From Tool to Experience
By expanding my basic View with these facets, the EBook library lab has shifted. It's no longer just a search engine; it's a research portal. I can now filter by the AI-generated metadata created in Part 4, finding "Summarized" content that is relevant to my current project in seconds.
What's Next?
I've built a powerful, beautiful, and intelligent system. But a library that stays hidden isn't reaching its full potential.
In the final part of this series, I'm going to look at continuously updating my library when I purchase new books. To do this, the existing migration will be hooked into a cron job to “watch” for new ebooks and, if found, kick off the process so the new books are available in the system. I'll also explore other possible uses and extensions for this to make it more robust and integrate with other systems.
Is your data easy to find, or just easy to store? If your team is struggling to navigate their own internal knowledge base, let's build a discovery engine that actually works for you.
The Drupal Odyssey Specialty: I thrive on building high-performance search integrations that turn stagnant data into accessible institutional knowledge.
0 Comments
Login or Register to post comments.