It seems that there's a pairing between a node's view and it's indexing.
You may add new data to the index easily, through the 'update index' hook but I think you can't modify data present in the node's view, which is included in the index by default, and cannot be removed. Node module's node_update_index hook calls the view hook and adds the result to the index. You may override this by implementing hook nodeapi 'view' but this will change the node's view.
Why do I need some fields to be viewed but NOT indexed? A good example is the CCK nodes. CCK view includes node's field labels and texts, and I don't want the labels to be indexed, just the texts. But of course, they should be part of the view output.
So my question is... how can I separate a node's view from its indexing so that the view isn't always included in the index?
There might be a solution for this (without patching core modules), but I don't know... the simplest thing I came up with is adding a flag to hook nodeapi('update index'), telling the hook caller to rewrite the index with the hook's result instead of appending it to the index previously build based on hook view.
I'm referring to the node_update_index() function, in node.module (this is the original code, I haven't done anything yet):
// Get node output (filtered and with module-specific fields).
if (node_hook($node, 'view')) {
node_invoke($node, 'view', false, false);
}
else {
$node = node_prepare($node, false);
}
// Allow modules to change $node->body before viewing.
node_invoke_nodeapi($node, 'view', false, false);
$text = '<h1>'. check_plain($node->title) .'</h1>'. $node->body;
// Fetch extra data normally not visible
$extra = node_invoke_nodeapi($node, 'update index');
foreach ($extra as $t) {
$text .= $t;
}
Any advice is welcome...
Comments
I have hacked node.module to
I have hacked node.module to get the functionality I needed. I'd like to know if there's a cleaner solution, though...
What I have done is create a new hook 'rewrite index'. When node module is creating indexes, it calls that hook, and, if it returns anything, overwrites the index with the new returned data (instead of appending it).
This goes in node.module, in the function node_update_index(), right before performing the search_index.
And then, in my module:
Comments?
Propose this feature for
Propose this feature for node.module.
I think that would be good if they iclude it in the further releases. May be they will suggest something instead...
----------------
Regards,
Dmitry Kresin, ARDAS group (www.ardas.dp.ua)
Where do we go with this?
I have been following this thread even though it's become quite cryptic to me. I am not a coder but I still want to help and to see this functionality.
My question is where can we expose this thread and it's parent thread so that more are aware of it to get it published into a module or core?
Let me know and I'll get right on it.
Thanks!
I have just submitted this
I have just submitted this issue to node.module's queue.
http://drupal.org/node/89871
Thanks for the issue! Hope
Thanks for the issue! Hope it will help us.
----------------
Regards,
Dmitry Kresin, ARDAS group (www.ardas.dp.ua)
Found a typo Where it says
Found a typo
Where it says
if(count($nodeData)) {it should sayif(count($indexData)) {of course...Sorry :)