I've created a new content type which has several fields (some of them are custom fields I created myself). Now I need to implement a search function on each of those fields.

This means that if I have these fields:

  • VideoCV (video field)
  • Occupation (text field)
  • Driving licence (select lists)
  • Region of birth (taxonomy term)

I need a search module with those four fields, so that if you search for occupation "engineer" it searches only data inserted in that specific field.

What do I need to do? What additional modules should I install? What should i do with my custom fields?


6 Answers 6


If you need to access the nodes in code, delmi's solution should work.

If you want to use existing modules, views should do the trick. I found NodeOne's video tutorials on views very helpful: http://dev.nodeone.se/node/781

  • In the end i used views and that tutorial is fantastic Mar 15, 2012 at 17:16
  • The node one links for later chapters is broken
    – pal4life
    May 19, 2014 at 18:22
  • All the links that I have tried still work for me.
    – Sam King
    May 19, 2014 at 22:06

I'm not a D7 expert but I you can try with an EntityFieldQuery like this:

$query = new EntityFieldQuery();
$entities = $query->entityCondition('entity_type', 'node')
                ->entityCondition('bundle', 'YOUR_CONTENT_TYPE_NAME')
                ->propertyCondition('status', 1)
                ->fieldCondition('YOUR_FIELD_NAME', 'value', $searchterm)
                // other conditions...
$nodes = entity_load('node', array_keys($entities['node']));

I wonder if Views and Better Exposed Filters would to the trick for you? Create a page view, expose your field filters, then in the "advanced" column to will have an option to show exposed filters in structure > blocks.


Create a view of your content type and add all the fields you want to search for as exposed filters. This creates a search form with input elements for all filtered fields (or just one if this is what you want). You can set it up to only filter for the filled input fields and ignore the other ones.

It let's you choose to put the search form on the top of your view or move it to a separate block.


Use the Finder module to build field-specific searches (Drupal's core search is a fulltext search, not field-specific). Here is an excerpt about it from the module's project page:

... allows Drupal site administrators to create flexible faceted search forms to find entities such as nodes or users based on the values of fields and database attributes.

Typically Finder is used for these purposes:

  • As a search tool to find a group of nodes or users.
  • As a way to navigate to a specific node or user page that matches criteria.
  • As an alternative to exposed filters for a Views module display.

Solution 1

Views 3 provides solution for your question from the box. It's the Global: Combine fields filter.

  1. Add fields

  2. Add Global: Combine fields filter to filter criteria

  3. Check fields you want to combine in filter's settings

If you use Display suite or teasers mode - force using fields in the View setting.

Solution 2

Views filters populate - good module. But there is 1 problem "only populates STRING exposed filters".

For more info, refer to the Views issue about Apply One Exposed Filter to Multiple Fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.