I was recently looking at all the default views that come with Drupal 8. For people who don’t know, the Views module is part of Drupal 8 core. In Drupal 7 and below it’s the most installed module so during Drupal 8’s development it was decided to move Views into core.
During my exploration into all of the default Views, I noticed that in the People (User) view there was a filter called “Combine fields filter”.
Now just a quick side note, if you’re new to Drupal and Views I’d highly recommend you spend time walking through all of the default views and see how they were configured. You can learn a lot just by seeing how things are set up.
The “Combine fields filter” does a pretty cool thing. It allows you to search across multiple fields or put another way, it allows you to combine fields and then filter by their combined value.
How to use “Combine Fields Filter”
Using this filter is relatively straightforward. Just click on Add in the Filter criteria field-set. Search for the filter by name or select Global from the Category drop-down.
When configuring the filter, you can select which fields you want to search from the “Choose fields to combine for filtering” drop-down.
If you want to see what the actual query looks like, turn on “Show the SQL query” from the Settings page (admin/structure/views/settings).
Then in the preview area, you should see the query that gets generated.
The above example is from the “People (User)” view.
If you want to add basic filtering across fields to your views, then this is the way to go. It’s useful for those custom admin pages which we create to help editors manage content. If you’re looking for something more advanced such as keyword searching, then look at using Search API.