About Features Downloads Getting Started Documentation Events Support GitHub

Site Tools

Warning: This page has not been updated in over over a year and may be outdated or deprecated.

Video 9: Combining Search Types

The ninth VuFind® instructional video explains how to combine multiple types of searches, using the example of configuring side-by-side catalog and website search results.

Video is available as an mp4 download or through YouTube.


In last month's video, we set up a web index and so we now have a VuFind instance that has both a catalog of bibliographic records and an index of web pages, which brings up the challenge of how to allow users to search both of these things. Fortunately, VuFind includes several mechanisms for combining searches and these mechanisms can be used separately or in combination depending on your needs. So in today's video, I'm going to show you how to combine searches side by side, how to create combined options in the search options drop down here, and how to use tabs to switch between multiple sets of search results on the fly.

We'll start with combined searching. Obviously, one of the challenges of having many different types of resources to search is figuring out how to present them to your user. And many libraries have found that an effective way of combining different types of search results is the so-called bento box approach, where a single set of search terms reveals a number of boxes of categorized content and then the user can navigate into whichever set of results are most appropriate for them. VuFind's combined searching mode provides a simple way of implementing this type of bento box searching. So I'm going to set that up first to allow us to search our web index and our bibliographic index side by side.

So here I am at the terminal in the VUFIND_HOME directory, and as with any other VuFind configuration, I'm going to start by copying the default configuration, which is the config/vufind/combined.ini into my local/config/vufind directory, establishing a local copy that I can edit. I will then edit that file. As with all of VuFind's configuration files, combined.ini has lots and lots of comments in it describing all of the contents of the file. There are a handful of reserved sections in here, which allow you to set global settings for combined searching, and the remainder of the sections each define one search box that will show up in the combined results.

So these comments at the top summarize everything, and once I get into the guts of the file, there's a basic searches section which defines which search types the user can choose. So for example, if you wanted to allow a fielded title, author, or subject search across all of your search boxes, you could uncomment some of these options to make that possible. But it's important to keep in mind that when you're combining search results, you can only turn on options that are supported in all of the boxes. So for the purposes of combining web results and bibliographic results, having search types to select doesn't make any sense because the fields are very different. So I'm going to leave all of this commented out. But if I were in a different scenario where I wanted to search two different kinds of things that both had titles, I would have the option of turning on title searching, which would allow the users to do more focused searching in their results.

The home page section here allows you to turn on contents on the main home screen of combined searching. By default, that screen is just going to show a search box. But by using content block plugins, which are described in more detail in searches.ini, you can add other content there, be it sort of a welcome message or details pulled in from other parts of you find.

The layout section controls how the boxes in your combined search are distributed on the screen. You can set how many columns of boxes that you want to show and how you want to wait the distribution of search boxes across the columns. So for example, if you had three columns and six types of searches, you could wave at the left or to the right or you could evenly spread it across the columns. In the simple two column example, I'm about to show you none of this will matter. We'll just get two boxes side by side. But in more complex setups, you may find these advanced settings helpful for controlling the priority and arrangement of all of the search options.

Before I get into the boxes themselves, of which there are a few examples here, I wanted to go down to the very bottom and point out that there's also this recommendation module section, which you can use to embed recommendations above or below all of the combined searches. So again, most of the time recommendation modules work best in the context of a particular type of search, but there are some situations where you may want to augment the overall result screen and this setting allows you to do that.

But now onto the really juicy part of this file, which are these sections defining search boxes. For each of these, the section name within the configuration file is actually the name of one of you find search backends, the code that actually retrieves search results. So any existing search backend can be embedded into combined searches by just creating a matching section name. So the example configuration includes sections for the summon and EDS services. Obviously, since we are not using those services in this example, we want to comment those out. But we're going to leave the solar section in place because that's where our bibliographic records live. And we also want to add a solar web section for the website because solar web is the name of the backend that handles web results.

Within the section, we need to provide a label which will be used to title the search results within the box. We could optionally include a sub label, which just provides some extra messaging within the box. If we set the more link that will provide a link from the combined search into the full result set for that box. And in theory, we can limit the number of results that show up. So by default, we get 10. But if we wanted to have more or fewer, we can adjust the limit here.

Another optional setting is the Ajax setting, which if we set to true will cause these search results to be retrieved asynchronously from the rest of the page. And Ajax loading of combined results can be really helpful, particularly when you have a large number of boxes. Or if some of your boxes are being loaded from slow third party services. Because if we don't use Ajax, all of the searches have to be executed and processed before the overall results page will load, which could be very slow, and will certainly be dragged down by whatever service runs the slowest. But if we use Ajax on some of the boxes, it will cause the mainstream to pop in fairly quickly and then additional results to load in as they become available.

So I've now set up the basic combined search settings for the bibliographic and website indexes. Let's see how that looks.

You can get to your combined search screen by simply adding the word combined to your VuFind URL. And as I mentioned, as it's configured by default, the homepage of the combined search is just a search box. But you can augment this by turning on content block settings in combined.ini. So let's search for web and see what the combined search results look like. As you can see, we've got two boxes of results on the left. We have catalog results. And on the right, we have website results. I'm also going to refresh the page one more time and draw your attention to the website area here just to highlight how that Ajax loading works. So as you can see, there is a link of the word loading here before the full results actually popped into place. So if you're using combined search, it is common that you would want this to be the first thing that users encounter when they come to your site because it offers the broadest view into your content. Right now, because I haven't changed default configurations, if I go back to the homepage of you find the default defined URL, I end up back in the bibliographic record search. But if I want to change that, it's very easy. I just need to edit my local/config/vufind/config.ini file. And there's a setting in here called default module, which defines the name of a controller that will be loaded by default from the defined homepage. This defaults to search, which searches the bibliographic index. But if I simply change this setting from search to combine, and then refresh my homepage here, now my default defined URL is taking me to the combined search. And you can use this for really anything you want to change to make your default defined behavior. So for example, if I wanted my website search to be the default, I could have changed that to web, etc. So it's great that we can now search these two different services at the same time. But our search experience can now become a little bit confusing unless we do some additional configuration. So you'll notice on this screen, my search box up here searches the combined search. But if I hit this more options link here and delve into the bibliographic record search, now I have the bibliographic record search box. I have no obvious way to get back to my combined search. And so I've changed context, but within an area of the screen that looks like it should remain consistent. Similarly, if I delve into the web results, I now have an identical looking search box to what I had on the combined screen. But if I search here, I'm searching the web results, and I have to hit the back button to return to my combined searches. Obviously, this is going to cause people to get lost in your site. But fortunately, there's a simple solution, which is the combined search box. Once again, there is simply a configuration file that controls the way do you find search box works. And we can manage that in the usual way. We'll copy the default version config/vufind/searchbox.ini into our local/config/vufind directory and we will edit that. Once again, we are faced with a file full of configuration settings and comments. But the thing that I want to mainly draw your attention to is this top setting combined handlers, which defaults to false.

If we set this to true, it's going to create a uniform search box that works the same everywhere in the VuFind site and encompasses all of the options from all of the different search backends. So we need to turn that on and then scroll down to the combined handlers section. Here, we need to activate all of the search backends that we want to show options for in our search dropdown. So the example configuration here shows Solr and Summon results. But we want Solr and website results. So I'm going to change the Summon example to Solr web with a label of website. So you'll notice that the way these settings are set up, you have groups of type, target, label, and group. It's very important that you copy all four settings when you add options here so that each of these name settings type, target, label, and group have the same number of values because otherwise the settings can get out of sync and cause weird results. So when you're adding things, just be sure you copy everything and fill in all of the settings. And I'm going to do just that because I need to add one more set of options here because we want to include the combined search option in addition to the individual catalog and website options.

So a couple more things to clarify here. There are two values that we can put in the type for each of these groups of handler settings. VuFind means we're working with an internal VuFind search back end and that we need to get all of our options from VuFind some internal code. And that's the most commonly used setting. So in that case, the target value is the name of a search back end. And the label is what we want to display as a label for that option within the dropdown. The group setting is optional. If you leave it false, nothing will happen. But if you have a very large number of handlers in play and you want to group them within the dropdown into labeled groups, you can provide a label here. But I recommend leaving that false in all but rare situations. The other type of handler you can set up is an external handler. Which allows you to actually link into searches on sites outside of VuFind. In this instance, when a user performs a search, VuFind will just take the URL you provide as the target of the external resource and append their search terms to the end of that. So in this example, we can perform a Google search directly from inside VuFind. Obviously, there's not really a good reason why you would want to do that most of the time. But if you're integrating VuFind with other local systems and you want to make them searchable, this is one way to achieve that kind of linking. Some other settings in this file that might potentially be of interest are include alpha browse, which allows you to embed links to VuFind alphabetical browse search within the main search box. That's a topic we haven't covered yet, but we may in the future. And then the remaining settings have to do with grouping options together and are usually safe to ignore. In any case, now that I've turned all of this on, if I refresh my combined search, you'll now see that I have a dropdown menu.

So here is my combined search. Here is my catalog search. And under the catalog search are all of the catalog specific search options that are provided through VuFind's internal configuration, the options from searches.ini. Then we have the website. And then at the bottom, that Google example. And as you can see, it's under a label called other sites because of the group setting. So if I wanted to group all of these things here under a label that looked like this, I could use the group setting to accomplish that. But importantly, we now have consistent search behavior. If I click on more options on my catalog search, it now shows that I'm doing a catalog search. I have a consistent set of controls. If I go back and I click into my web result, again, now it shows that I'm doing a website search, but all of the same options are available everywhere. So I strongly recommend configuring a combined search box at the same time that you set up a combined search. And then there is just one last detail which is optional but useful, which is turning on search tabs, which just provides another way for users to navigate between different types of search results.

I'll go back to my terminal and I will once again edit my main config.ini file. In this file, there is a section called search tabs, which by default is all commented out. But you can here create mappings from search backend names to labels in order to turn on tabs in your search results. So I'm going to uncomment the Solr equals catalog option. I'm going to add combined equals combined and Solr web equals website so that it's possible to tab between all three search options, the combined and the two individual. So just by adding those three lines of configuration, if I now go back to my search results and refresh them, I now have tabs on my search box. And if I click on them, they will switch me back and forth between the three different search modes pertaining my search terms. So with all three of these things in place, we have access to every kind of search from every page of VuFind through this drop down menu here. Once we perform a search, we can navigate to different kinds of searches with a single click through the tabs. And by configuring the combined search, we have this high level view of all of our search results from multiple locations on a single screen. Utilizing all of these things together, we offer our users very flexible access to the content that we're providing. It can of course get a lot more complicated as you add a lot more content, figuring out how to label your boxes and what kinds of messaging to use can be quite a challenge. But at least you find provides the technical framework to easily experiment with different arrangements and different labels and make all of your stuff visible.

That is all I have for this month. But I thank you for your time and I will have more next time. Thanks again.

This is an edited version of an automated transcript. Apologies for any errors.

videos/combining_search_types.txt · Last modified: 2023/04/26 13:29 by crhallberg