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_partial_index()

Description

Generates a list of keywords for indexing, including all possible infixes
for each keyword in the provided list.

This function processes each keyword and, for those without spaces,
adds all possible infixes of a specified minimum length to the return array.
The resulting array is suitable for indexing in fields that have partial indexing enabled.

Parameters

ColumnTypeDefaultDescription
$keywords array An array of keywords to process for partial indexing.

Return

array An array of keywords, each with its associated position in the original list.

Location

include/search_functions.php lines 2492 to 2522

Definition

 
function add_partial_index($keywords)
    {
    
$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 13th December 2024 20:35 Europe/London time based on the source file dated 12th December 2024 10:30 Europe/London time.