The searchnodelinks table
The tokens in Figure 3 didn't contain any links. Here's some text that links back to node 2 (the node that talks about ponies and badgers):
<a href="http://example.com/node/2">Talk of badgers and ponies</a>
This is in node 3, and the link references node 2. Now look at the contents of the search_node_links table after node 3 has been indexed:
mysql> select * from search_node_links;
|
sid 1 type |
1 |
nid 1 |
caption |
|
3 1 node |
1 |
2 1 |
talk badgers and ponies |
Figure 18: search_node_links has "caption" text that will be added to a node's text at indexing time.
The utility of this text only makes sense if we also look at the search_nodeapi function:
<?php function search_nodcapi(sSnode, Sop, Steaser - NULL, Spagc ■ NULL) { switch (Sop) {
ease 'update index':
Sresult ■ db_query("SELECT caption FROM {scarch_node_links} WHERE nid %d", Snode->nid);
while (Slink - db_fetch_object(Sresult)) { Slinks[] - Slink->caption;
Soutput " '<a>(' . implodo(', Soutput) . ')</a>';
return Soutput;
Figure 19: The search_nodeapi function takes care that the text from referencing links gets added to a node's text at indexing time.
Here you can see that before a node gets indexed, it's text is extended with all of the link text from nodes that reference it. The referring link texts get wrapped in <a> tags to boost the score of the words appropriately.
Post a comment