Search code examples
drupalcckdrupal-nodesdrupal-search

Searching custom nodes' by field in Drupal?


Using Drupal on a project which I made custom node types in using the CCK. I want to be able to search the specific node based on a custom field the node has. So let's say I have this node type Article which has a field "myfield", I want to be able to search for Articles based on the myfield field. I understand the default search module allows for searching of node types using the type:MyNodeType in the search, but I did not see any way to limit which fields are searched. Any tips? Is this something that is going to get crazy? Appreciate the help.


Solution

  • The default search cannot filter by specific fields.

    You have a couple options.

    • Write custom code that filters again the actual fields in the database.
    • Use the Views module, which lets you filter against specific fields.
    • Install the ApacheSolr search engine, which can filter against specific fields.
      • This is a fairly complex thing to install.
      • If you're comfortable installing it, though, it's a better and more flexible search than the other two options.