How to limit drupal search from indexing all types of content?

I want certain nodes to be indexed. The "search config" module claims to have this capability, but it does not work. So, how do I either edit the node module to index only certain nodes, or better yet, implement a module that can do this for me?

+5
source share
2 answers

This is a long-running feature request , but it looks like it has already been pressed, at least on Drupal 8: /

You can find some workarounds in the discussion of function descriptions, but the “standard” approach used in the search configuration module is described here . This does not interfere with indexing nodes, but it manipulates search queries to ignore certain records (for example, node types) so that they do not appear on search results pages.

Since there is currently no clearly better solution (afaik), I agree with ceejayoz's comment that you should first check why the search configuration module does not work for you before proceeding with custom coding of your own solution.

If you need to resort to editing the node module itself, this node_update_index()is the place to start.

+3

, , , node_update_index():

SELECT n.nid FROM {node} n 
  LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid 
  WHERE d.sid IS NULL OR d.reindex <> 0
  ORDER BY d.reindex ASC, n.nid ASC

script. , {search_dataset}.

, MySQL, cron:

INSERT INTO {search_dataset} 
  (sid, type, data, reindex)
  SELECT nid, 'node', '', 0 FROM {node} WHERE node.type IN (RESTRICTED_TYPES)
  ON DUPLICATE KEY UPDATE reindex = 0, data = ''

"RESTRICTED_TYPES" node , .

+3

All Articles