Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

add_partial_index()

Parameters

ColumnTypeDefaultDescription
$keywords

Location

include/search_functions.php lines 2038 to 2071

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 10th July 2020 20:05 Europe/London time based on the source file dated 7th July 2020 15:22 Europe/London time.