Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 1048 to 1078

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 4th December 2024 09:05 Europe/London time based on the source file dated 28th November 2024 12:10 Europe/London time.