I have a custom module that stores text records in a table, however this table records are not mapped to nor an entity neither a node, so as far as I know, I can't expose them to the search module or the search API.

So my question is how do I expose my data (custom table fields) to Drupal so I can use some sort of search module (preferably search API or the core search) ?.


You can use

To define your own search type and add the required data to the index.

  • I have taken a look at those hooks, however I can't see how (without a custom content type) I can integrate my module with the core search. Will take a closer look but any hints on doing it will be much appreciated.
    – drcelus
    Feb 19 '13 at 12:01

I really think it is good practice to store the data as entities making you able to use views, search, editing, permissions, ... Take a look at the following snippet on how to store your data as entities. Use the Entity Construction Kit (ECK) module to create the entity bundle, type and fields and store your data like this:

$new_ent = entity_create('TYPENAME_YOU_DEFINE_IN_ECK', array(
  'uid' => 1, // the uid that created this record

You'll even get an admin interface from ECK for free. After the creation, you can index the data also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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