CWIS Developer Documentation
|
Core metadata archive search engine class. More...
Public Member Functions | |
__construct ($ItemTableName, $ItemIdFieldName) | |
Object constructor. More... | |
AddField ($FieldName, $FieldType, $Weight, $UsedInKeywordSearch) | |
Add field to include in searching. More... | |
FieldType ($FieldName) | |
Get type of specified field (text/numeric/date/daterange). More... | |
FieldWeight ($FieldName) | |
Get search weight for specified field. More... | |
FieldInKeywordSearch ($FieldName) | |
Get whether specified field is included in keyword searches. More... | |
DebugLevel ($NewValue) | |
Set debug output level. More... | |
Search ($SearchString, $StartingResult=0, $NumberOfResults=10, $SortByField=NULL, $SortDescending=TRUE) | |
Perform search. More... | |
FieldedSearch ($SearchStrings, $StartingResult=0, $NumberOfResults=10, $SortByField=NULL, $SortDescending=TRUE) | |
Perform search across multiple fields, with different values or comparisons specified for each field. More... | |
GroupedSearch ($SearchGroups, $StartingResult=0, $NumberOfResults=10, $SortByField=NULL, $SortDescending=TRUE) | |
Perform search with logical groups of fielded searches. More... | |
AddResultFilterFunction ($FunctionName) | |
Add function that will be called to filter search results. More... | |
DefaultSearchLogic ($NewSetting=NULL) | |
Get/set default search logic (LOGIC_AND or LOGIC_OR). More... | |
SearchTermsRequiredByDefault ($NewSetting=TRUE) | |
Set default search logic. More... | |
NumberOfResults () | |
Get number of results found by most recent search. More... | |
SearchTerms () | |
Get normalized list of search terms. More... | |
SearchTime () | |
Get time that last search took, in seconds. More... | |
FieldedSearchWeightScale ($SearchStrings) | |
Get total of weights for all fields involved in search, useful for assessing scale of scores in search results. More... | |
UpdateForItem ($ItemId, $ItemType=0) | |
Update search database for the specified item. More... | |
UpdateForItems ($StartingItemId, $NumberOfItems) | |
Update search database for the specified range of items. More... | |
DropItem ($ItemId) | |
Drop all data pertaining to item from search database. More... | |
DropField ($FieldName) | |
Drop all data pertaining to field from search database. More... | |
SearchTermCount () | |
Get total number of search terms indexed by search engine. More... | |
ItemCount () | |
Get total number of items indexed by search engine. More... | |
AddSynonyms ($Word, $Synonyms) | |
Add synonyms. More... | |
RemoveSynonyms ($Word, $Synonyms=NULL) | |
Remove synonym(s). More... | |
RemoveAllSynonyms () | |
Remove all synonyms. More... | |
GetSynonyms ($Word) | |
Get synonyms for word. More... | |
GetAllSynonyms () | |
Get all synonyms. More... | |
SetAllSynonyms ($SynonymList) | |
Set all synonyms. More... | |
LoadSynonymsFromFile ($FileName) | |
Load synonyms from a file. More... | |
Public Attributes | |
const | LOGIC_AND = 1 |
const | LOGIC_OR = 2 |
const | FIELDTYPE_TEXT = 1 |
const | FIELDTYPE_NUMERIC = 2 |
const | FIELDTYPE_DATE = 3 |
const | FIELDTYPE_DATERANGE = 4 |
const | WORD_PRESENT = 1 |
const | WORD_EXCLUDED = 2 |
const | WORD_REQUIRED = 4 |
const | STEM_ID_OFFSET = 1000000 |
const | SEARCHLOGIC_AND = 1 |
const | SEARCHLOGIC_OR = 2 |
Protected Member Functions | |
SearchFieldForPhrases ($FieldName, $Phrase) | |
FilterOnSuppliedFunctions ($Scores) | |
GetFieldContent ($ItemId, $FieldName) | |
DMsg ($Level, $Msg) | |
Protected Attributes | |
$DB | |
$DebugLevel | |
$ItemTableName | |
$ItemIdFieldName | |
$NumberOfResultsAvailable | |
$LastSearchTime | |
$FilterFuncs | |
$DefaultSearchLogic = self::LOGIC_AND | |
$StemmingEnabled = TRUE | |
$SynonymsEnabled = TRUE | |
Core metadata archive search engine class.
Definition at line 13 of file SearchEngine.php.
SearchEngine::__construct | ( | $ItemTableName, | |
$ItemIdFieldName | |||
) |
Object constructor.
string | $ItemTableName | Name of database table containing items. |
string | $ItemIdFieldName | Name of column in item database table containing item IDs. |
Definition at line 38 of file SearchEngine.php.
References $ItemIdFieldName, $ItemTableName, and DebugLevel().
SearchEngine::AddField | ( | $FieldName, | |
$FieldType, | |||
$Weight, | |||
$UsedInKeywordSearch | |||
) |
Add field to include in searching.
string | $FieldName | Name of field. |
int | $FieldType | Type of field (FIELDTYPE_ constant value). |
int | $Weight | Numeric search weight for field. |
bool | $UsedInKeywordSearch | If TRUE, field is included in keyword searches. |
Definition at line 59 of file SearchEngine.php.
Referenced by SPTSearchEngine\__construct().
SearchEngine::AddResultFilterFunction | ( | $FunctionName | ) |
Add function that will be called to filter search results.
callable | $FunctionName | Function to be called. |
Definition at line 391 of file SearchEngine.php.
SearchEngine::AddSynonyms | ( | $Word, | |
$Synonyms | |||
) |
Add synonyms.
string | $Word | Word for which synonyms should apply. |
array | $Synonyms | Array of synonyms. |
Definition at line 619 of file SearchEngine.php.
Referenced by LoadSynonymsFromFile(), and SetAllSynonyms().
SearchEngine::DebugLevel | ( | $NewValue | ) |
Set debug output level.
Values above zero trigger diagnostic output.
int | $NewValue | New debugging level. |
Definition at line 103 of file SearchEngine.php.
Referenced by __construct(), and SPTSearchEngine\SearchFieldForPhrases().
SearchEngine::DefaultSearchLogic | ( | $NewSetting = NULL | ) |
Get/set default search logic (LOGIC_AND or LOGIC_OR).
enum | $NewSetting | New search logic setting. (OPTIONAL) |
Definition at line 402 of file SearchEngine.php.
References $DefaultSearchLogic.
Referenced by GroupedSearch(), SPTSearchEngine\SearchFieldsForComparisonMatches(), and SearchTermsRequiredByDefault().
|
protected |
Definition at line 2178 of file SearchEngine.php.
Referenced by FieldedSearch(), GroupedSearch(), Search(), SPTSearchEngine\SearchFieldForPhrases(), and SPTSearchEngine\SearchFieldsForComparisonMatches().
SearchEngine::DropField | ( | $FieldName | ) |
Drop all data pertaining to field from search database.
string | $FieldName | Name of field to drop. |
Definition at line 579 of file SearchEngine.php.
SearchEngine::DropItem | ( | $ItemId | ) |
Drop all data pertaining to item from search database.
int | $ItemId | ID of item to drop from database. |
Definition at line 568 of file SearchEngine.php.
SearchEngine::FieldedSearch | ( | $SearchStrings, | |
$StartingResult = 0 , |
|||
$NumberOfResults = 10 , |
|||
$SortByField = NULL , |
|||
$SortDescending = TRUE |
|||
) |
Perform search across multiple fields, with different values or comparisons specified for each field.
This method is DEPRECATED – please use SearchEngine::Search() with a SearchParameterSet object instead.
array | $SearchStrings | Array of search strings, with field names for index. |
int | $StartingResult | Starting index into results. (OPTIONAL, defaults to 0) |
int | $NumberOfResults | Number of results to return. (OPTIONAL, defaults to 10) |
string | $SortByField | Name of field to sort results by. (OPTIONAL, defaults to relevance score) |
bool | $SortDescending | If TRUE, results will be sorted in descending order, otherwise results will be sorted in ascending order. (OPTIONAL, defaults to TRUE) |
Definition at line 214 of file SearchEngine.php.
References DMsg(), and GroupedSearch().
SearchEngine::FieldedSearchWeightScale | ( | $SearchStrings | ) |
Get total of weights for all fields involved in search, useful for assessing scale of scores in search results.
array | $SearchStrings | Array of arrays of search strings, with field names for index. |
Definition at line 455 of file SearchEngine.php.
SearchEngine::FieldInKeywordSearch | ( | $FieldName | ) |
Get whether specified field is included in keyword searches.
string | $FieldName | Name of field. |
Definition at line 94 of file SearchEngine.php.
SearchEngine::FieldType | ( | $FieldName | ) |
Get type of specified field (text/numeric/date/daterange).
string | $FieldName | Name of field. |
Definition at line 74 of file SearchEngine.php.
SearchEngine::FieldWeight | ( | $FieldName | ) |
Get search weight for specified field.
string | $FieldName | Name of field. |
Definition at line 84 of file SearchEngine.php.
|
protected |
Definition at line 1840 of file SearchEngine.php.
SearchEngine::GetAllSynonyms | ( | ) |
Get all synonyms.
Definition at line 749 of file SearchEngine.php.
|
protected |
Definition at line 2135 of file SearchEngine.php.
Referenced by UpdateForItem().
SearchEngine::GetSynonyms | ( | $Word | ) |
Get synonyms for word.
string | $Word | Word for which synonyms should apply. |
Definition at line 711 of file SearchEngine.php.
SearchEngine::GroupedSearch | ( | $SearchGroups, | |
$StartingResult = 0 , |
|||
$NumberOfResults = 10 , |
|||
$SortByField = NULL , |
|||
$SortDescending = TRUE |
|||
) |
Perform search with logical groups of fielded searches.
This method is DEPRECATED – please use SearchEngine::Search() with a SearchParameterSet object instead.
mixed | $SearchGroups | Search parameters as SearchParameterSet object or legacy array format. |
int | $StartingResult | Starting index into results. (OPTIONAL, defaults to 0) |
int | $NumberOfResults | Number of results to return. (OPTIONAL, defaults to 10) |
string | $SortByField | Name of field to sort results by. (OPTIONAL, defaults to relevance score) |
bool | $SortDescending | If TRUE, results will be sorted in descending order, otherwise results will be sorted in ascending order. (OPTIONAL, defaults to TRUE) |
Definition at line 267 of file SearchEngine.php.
References $DefaultSearchLogic, DefaultSearchLogic(), and DMsg().
Referenced by FieldedSearch(), and Search().
SearchEngine::ItemCount | ( | ) |
Get total number of items indexed by search engine.
Definition at line 606 of file SearchEngine.php.
SearchEngine::LoadSynonymsFromFile | ( | $FileName | ) |
Load synonyms from a file.
Each line of file should contain one word at the beginning of the line, followed by one or more synonyms separated by spaces or commas. Blank lines or lines beginning with "#" (i.e. comments) will be ignored.
string | $FileName | Name of file containing synonyms (with path if needed). |
Definition at line 864 of file SearchEngine.php.
References AddSynonyms().
SearchEngine::NumberOfResults | ( | ) |
Get number of results found by most recent search.
Definition at line 425 of file SearchEngine.php.
References $NumberOfResultsAvailable.
SearchEngine::RemoveAllSynonyms | ( | ) |
Remove all synonyms.
Definition at line 701 of file SearchEngine.php.
Referenced by SetAllSynonyms().
SearchEngine::RemoveSynonyms | ( | $Word, | |
$Synonyms = NULL |
|||
) |
Remove synonym(s).
string | $Word | Word for which synonyms should apply. |
array | $Synonyms | Array of synonyms to remove. If not specified, all synonyms for word will be removed. (OPTIONAL) |
Definition at line 659 of file SearchEngine.php.
SearchEngine::Search | ( | $SearchString, | |
$StartingResult = 0 , |
|||
$NumberOfResults = 10 , |
|||
$SortByField = NULL , |
|||
$SortDescending = TRUE |
|||
) |
Perform search.
string | $SearchString | Keyword string to search for or SearchParameterSet object. |
int | $StartingResult | Starting index into results. (OPTIONAL, defaults to 0) |
int | $NumberOfResults | Number of results to return. (OPTIONAL, defaults to 10) |
string | $SortByField | Name of field to sort results by. (OPTIONAL, defaults to relevance score) |
bool | $SortDescending | If TRUE, results will be sorted in descending order, otherwise results will be sorted in ascending order. (OPTIONAL, defaults to TRUE) |
Definition at line 127 of file SearchEngine.php.
References DMsg(), and GroupedSearch().
|
protected |
Definition at line 1603 of file SearchEngine.php.
SearchEngine::SearchTermCount | ( | ) |
Get total number of search terms indexed by search engine.
Definition at line 596 of file SearchEngine.php.
SearchEngine::SearchTerms | ( | ) |
Get normalized list of search terms.
Definition at line 434 of file SearchEngine.php.
SearchEngine::SearchTermsRequiredByDefault | ( | $NewSetting = TRUE | ) |
Set default search logic.
bool | $NewSetting | If TRUE then default logic is LOGIC_AND, otherwise default logic is LOGIC_OR. |
Definition at line 416 of file SearchEngine.php.
References DefaultSearchLogic().
SearchEngine::SearchTime | ( | ) |
Get time that last search took, in seconds.
Definition at line 443 of file SearchEngine.php.
References $LastSearchTime.
SearchEngine::SetAllSynonyms | ( | $SynonymList | ) |
Set all synonyms.
This removes any existing synonyms and replaces them with the synonyms passed in.
array | $SynonymList | Array of arrays of synonyms, with words for index. |
Definition at line 843 of file SearchEngine.php.
References AddSynonyms(), and RemoveAllSynonyms().
SearchEngine::UpdateForItem | ( | $ItemId, | |
$ItemType = 0 |
|||
) |
Update search database for the specified item.
int | $ItemId | ID of item. |
int | $ItemType | Numerical type of item. |
Definition at line 494 of file SearchEngine.php.
References GetFieldContent().
Referenced by UpdateForItems(), and SPTSearchEngine\UpdateForResource().
SearchEngine::UpdateForItems | ( | $StartingItemId, | |
$NumberOfItems | |||
) |
Update search database for the specified range of items.
int | $StartingItemId | ID of item to start with. |
int | $NumberOfItems | Maximum number of items to update. |
Definition at line 545 of file SearchEngine.php.
References UpdateForItem().
|
protected |
Definition at line 904 of file SearchEngine.php.
Referenced by SPTSearchEngine\GetResultFacets().
|
protected |
Definition at line 905 of file SearchEngine.php.
|
protected |
Definition at line 911 of file SearchEngine.php.
Referenced by DefaultSearchLogic(), and GroupedSearch().
|
protected |
Definition at line 910 of file SearchEngine.php.
|
protected |
Definition at line 907 of file SearchEngine.php.
Referenced by __construct().
|
protected |
Definition at line 906 of file SearchEngine.php.
Referenced by __construct().
|
protected |
Definition at line 909 of file SearchEngine.php.
Referenced by SearchTime().
|
protected |
Definition at line 908 of file SearchEngine.php.
Referenced by NumberOfResults().
|
protected |
Definition at line 912 of file SearchEngine.php.
|
protected |
Definition at line 913 of file SearchEngine.php.
const SearchEngine::FIELDTYPE_DATE = 3 |
Definition at line 24 of file SearchEngine.php.
const SearchEngine::FIELDTYPE_DATERANGE = 4 |
Definition at line 25 of file SearchEngine.php.
const SearchEngine::FIELDTYPE_NUMERIC = 2 |
Definition at line 23 of file SearchEngine.php.
const SearchEngine::FIELDTYPE_TEXT = 1 |
Definition at line 22 of file SearchEngine.php.
const SearchEngine::LOGIC_AND = 1 |
const SearchEngine::LOGIC_OR = 2 |
Definition at line 19 of file SearchEngine.php.
Referenced by SearchParameterSet\GetAsLegacyArray(), SavedSearch\SearchGroups(), and SavedSearch\TranslateUrlParametersToSearchGroups().
const SearchEngine::SEARCHLOGIC_AND = 1 |
Definition at line 2189 of file SearchEngine.php.
const SearchEngine::SEARCHLOGIC_OR = 2 |
Definition at line 2190 of file SearchEngine.php.
const SearchEngine::STEM_ID_OFFSET = 1000000 |
Definition at line 924 of file SearchEngine.php.
const SearchEngine::WORD_EXCLUDED = 2 |
Definition at line 29 of file SearchEngine.php.
const SearchEngine::WORD_PRESENT = 1 |
Definition at line 28 of file SearchEngine.php.
const SearchEngine::WORD_REQUIRED = 4 |
Definition at line 30 of file SearchEngine.php.