Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

add_node_keyword()

Description

Adds node keyword for indexing purposes

Parameters

ColumnTypeDefaultDescription
$node integer ID of the node (from node table) the keyword should be linked to
$keyword string Keyword to index
$position integer The position of the keyword in the string that was indexed
$normalize true
$stem true
$normalized boolean If this keyword is normalized by the time we add it, set as true

Return

boolean

Location

include/node_functions.php lines 1029 to 1059

Definition

 
function add_node_keyword($node$keyword$position$normalize true$stem true)
    {
    global 
$noadd$stemming;

    
debug("add_node_keyword: node:" $node ", keyword: " $keyword ", position: " $position ", normalize:" . ($normalize?"TRUE":"FALSE") . ", stem:" . ($stem?"TRUE":"FALSE"));

     
$unstemmed=$keyword;
     if (
$stem && $stemming && function_exists("GetStem"))
        {
        
$keyword=GetStem($keyword);
        if(
$keyword!=$unstemmed)
            {
            
// $keyword has been changed by stemming, also index the original value
            
debug("add_node_keyword - adding unstemmed: " $unstemmed);
            
add_node_keyword($node$unstemmed$position$normalize,false);
            }
        }
        
        
    
// $keyword should not be indexed if it can be found in the $noadd array, no need to continue
    
if(in_array($unstemmed$noadd))
        {
        
debug('Ignored keyword "' $keyword '" as it is in the $noadd array. Triggered in ' __FUNCTION__ '() on line ' __LINE__);
        return 
false;
        }

    
$keyword_ref resolve_keyword($keywordtrue,$normalize,false); // We have already stemmed

    
ps_query("INSERT INTO node_keyword (node, keyword, position) VALUES (?, ?, ?)",array("i",$node,"i",$keyword_ref,"i",$position));
    return 
true;
    }

This article was last updated 22nd May 2024 16:05 Europe/London time based on the source file dated 14th May 2024 18:25 Europe/London time.