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

add_partial_index()

Parameters

ColumnTypeDefaultDescription
$keywords

Location

include/search_functions.php lines 2363 to 2396

Definition

 
function add_partial_index($keywords)
    {
    
# For each keywords in the supplied keywords list add all possible infixes and return the combined array.
    # This therefore returns all keywords that need indexing for the given string.
    # Only for fields with 'partial_index' enabled.
    
$return=array();
    
$position=0;
    
$x=0;
    for (
$n=0;$n<count($keywords);$n++)
        {
        
$keyword=trim($keywords[$n]);
        
$return[$x]['keyword']=$keyword;
        
$return[$x]['position']=$position;
        
$x++;
        if (
strpos($keyword," ")===false# Do not do this for keywords containing spaces as these have already been broken to individual words using the code above.
            
{
            global 
$partial_index_min_word_length;
            
# For each appropriate infix length
            
for ($m=$partial_index_min_word_length;$m<strlen($keyword);$m++)
                {
                
# For each position an infix of this length can exist in the string
                
for ($o=0;$o<=strlen($keyword)-$m;$o++)
                    {
                    
$infix=mb_substr($keyword,$o,$m);
                    
$return[$x]['keyword']=$infix;
                    
$return[$x]['position']=$position// infix has same position as root
                    
$x++;
                    }
                }
            } 
# End of no-spaces condition
        
$position++; // end of root keyword
        
# End of partial indexing keywords loop
    
return $return;
    }

This article was last updated 19th March 2024 03:05 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.