CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | List of all members
SPTSearchEngine Class Reference
Inheritance diagram for SPTSearchEngine:
[legend]
Collaboration diagram for SPTSearchEngine:
[legend]

## Public Member Functions
| __construct ()
| Class constructor. More...
| GetFieldContent ($ItemId, $FieldId)
| Overloaded version of method to retrieve text from DB. More...
| SearchFieldForPhrases ($FieldId, $Phrase)
| Perform phrase searching. More...
| SearchFieldsForComparisonMatches ($FieldIds, $Operators, $Values, $Logic)
| Perform comparison searches. More...
| GroupedSearch ($SearchGroups, $StartingResult=0, $NumberOfResults=10, $SortByField=NULL, $SortDescending=TRUE)
| Perform search with logical groups of fielded searches. More...
Public Member Functions inherited from SearchEngine
| __construct ($ItemTableName, $ItemIdFieldName, $ItemTypeFieldName)
| Object constructor. More...
| AddField ($FieldId, $FieldType, $ItemTypes, $Weight, $UsedInKeywordSearch)
| Add field to include in searching. More...
| FieldType ($FieldId)
| Get type of specified field (text/numeric/date/daterange). More...
| FieldWeight ($FieldId)
| Get search weight for specified field. More...
| FieldInKeywordSearch ($FieldId)
| Get whether specified field is included in keyword searches. More...
| DebugLevel ($NewValue)
| Set debug output level. More...
| Search ($SearchParams)
| Perform search with specified parameters, returning results in a flat array indexed by item ID. More...
| SearchAll ($SearchParams)
| Perform search with specified parameters, returning results separated by item type. More...
| AddResultFilterFunction ($FunctionName)
| Add function that will be called to filter search results. More...
| NumberOfResults ($ItemType=NULL)
| 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 ($SearchParams)
| Get total of weights for all fields involved in search, useful for assessing scale of scores in search results. More...
| UpdateForItem ($ItemId, $ItemType)
| 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 ($FieldId)
| 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...

## Static Public Member Functions
static | GetItemIdsSortedByField ($ItemType, $FieldId, $SortDescending)
| Return item IDs sorted by a specified field. More...
static | QueueUpdateForItem ($ItemOrItemId, $TaskPriority=NULL)
| Queue background update for an item. More...
static | RunUpdateForItem ($ItemId)
| Update search index for an item. More...
static | GetResultFacets ($SearchResults, $User)
| Generate a list of suggested additional search terms that can be used for faceted searching. More...
static | SetUpdatePriority ($NewPriority)
| Set the default priority for background tasks. More...
static | SetNumResourcesForFacets ($NumToUse)
| Set the number of resources used for search facets. More...
static | QueueDBRebuildForSchema ($SchemaId)
| Queue background rebuild of search database for all items for specified schema. More...
static | QueueDBRebuildForAllSchemas ()
| Queue background rebuild of search database for all items for all schemas. More...
static | FilterTextDisplay ($ParamDesc)
| Filter for text display of search parameters. More...
Static Public Member Functions inherited from SearchEngine
static | FlattenMultiTypeResults ($Results)
| Flatten a two-dimensional array keyed by ItemType with results for each type as the outer values into array(ItemId => ItemScore). More...
static | BuildMultiTypeResults ($Results)
| Expand a one-dimensional array(ItemId => ItemScore) into a two-dimensional array(ItemType => array(ItemId => ItemScore)). More...

## Additional Inherited Members
Public Attributes inherited from SearchEngine
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 | KEYWORD_FIELD_ID = -100
const | STEM_ID_OFFSET = 1000000
const | SEARCHLOGIC_AND = 1
const | SEARCHLOGIC_OR = 2
const | COMPARISON_OPERATOR_PATTERN = '/^([><=^$@]+|!=)([^><=^$@])/'
Protected Member Functions inherited from SearchEngine
| SearchFieldForPhrases ($FieldId, $Phrase)
| Search for phrase in specified field. More...
| FilterOnSuppliedFunctions ($Scores)
| Filter search scores through any supplied functions. More...
| GetFieldContent ($ItemId, $FieldId)
| Retrieve content for specified field for specified item. More...
| DMsg ($Level, $Msg)
| Print debug message if level set high enough. More...
Protected Attributes inherited from SearchEngine
| $DB
| $DebugLevel
| $FilterFuncs
| $ItemIdFieldName
| $ItemTableName
| $ItemTypeFieldName
| $LastSearchTime
| $NumberOfResultsAvailable
| $NumberOfResultsPerItemType
| $StemmingEnabled = TRUE
| $SynonymsEnabled = TRUE

## Detailed Description

Definition at line 10 of file SPTSearchEngine.php.

## Constructor & Destructor Documentation

SPTSearchEngine::__construct | ( |  | ) |

Class constructor.

Definition at line 15 of file SPTSearchEngine.php.

References SearchEngine\AddField(), MetadataSchema\GetAllSchemas(), MetadataSchema\MDFTYPE_CONTROLLEDNAME, MetadataSchema\MDFTYPE_DATE, MetadataSchema\MDFTYPE_FILE, MetadataSchema\MDFTYPE_FLAG, MetadataSchema\MDFTYPE_IMAGE, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_OPTION, MetadataSchema\MDFTYPE_PARAGRAPH, MetadataSchema\MDFTYPE_POINT, MetadataSchema\MDFTYPE_REFERENCE, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\MDFTYPE_TREE, MetadataSchema\MDFTYPE_URL, and MetadataSchema\MDFTYPE_USER.

## Member Function Documentation

static SPTSearchEngine::FilterTextDisplay | ( |  | $ParamDesc | ) |
| static

Filter for text display of search parameters.

Parameters

  string | $ParamDesc | Unfiltered parameter description.

Returns
  string Modified parameter description.

Definition at line 1005 of file SPTSearchEngine.php.

References SearchEngine\$DB, and ApplicationFramework\PRIORITY_BACKGROUND.

SPTSearchEngine::GetFieldContent | ( |  | $ItemId,
|  |  | $FieldId
| ) |  |

Overloaded version of method to retrieve text from DB.

Parameters

  int | $ItemId | ID of item to retrieve value for.
  string | $FieldId | ID of field to retrieve value for.

Returns
  mixed Text value or array of text values or NULL or empty array if no values available.

Definition at line 89 of file SPTSearchEngine.php.

References MetadataSchema\MDFTYPE_REFERENCE.

static SPTSearchEngine::GetItemIdsSortedByField | ( |  | $ItemType,
|  |  | $FieldId,
|  |  | $SortDescending
| ) |  |
| static

Return item IDs sorted by a specified field.

Parameters

  int | $ItemType | Type of item.
  int | $FieldId | ID of field by which to sort.
  bool | $SortDescending | If TRUE, sort in descending order, otherwise sort in ascending order.

Returns
  array of ItemIds

Definition at line 646 of file SPTSearchEngine.php.

static SPTSearchEngine::GetResultFacets | ( |  | $SearchResults,
|  |  | $User
| ) |  |
| static

Generate a list of suggested additional search terms that can be used for faceted searching.

Parameters

  array | $SearchResults | A set of results from a from which to generate facets.
  User | $User | User to employ in permission checks.

Returns
  An array of suggestions. Keys are the field names and values are arrays of (ValueId => SuggestedValue)

Definition at line 728 of file SPTSearchEngine.php.

References SearchEngine\$DB, and MetadataSchema\MDFSTAT_OK.

Referenced by SearchFacetUI\__construct().

Here is the caller graph for this function:

SPTSearchEngine::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.

Parameters

  mixed | $SearchGroups | Search parameters as SearchParameterSet object or legacy array format.
  int | $StartingResult | Starting index into results. (OPTIONAL, defaults to 0) (NO LONGER SUPPORTED - PARAMETER IS IGNORED)
  int | $NumberOfResults | Number of results to return. (OPTIONAL, defaults to 10) (NO LONGER SUPPORTED - PARAMETER IS IGNORED)
  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)

Returns
  array Array of search result scores, with the IDs of items found by search as the index.

See also
  SearchEngine::Search()

Definition at line 960 of file SPTSearchEngine.php.

References MetadataSchema\SCHEMAID_DEFAULT, and SearchEngine\Search().

static SPTSearchEngine::QueueDBRebuildForAllSchemas | ( |  | ) |
| static

Queue background rebuild of search database for all items for all schemas.

Returns
  int Number of items queued for rebuild.

Definition at line 926 of file SPTSearchEngine.php.

References MetadataSchema\GetAllSchemas().

static SPTSearchEngine::QueueDBRebuildForSchema | ( |  | $SchemaId | ) |
| static

Queue background rebuild of search database for all items for specified schema.

Parameters

  int | $SchemaId | ID of schema.

Returns
  int Number of items queued for rebuild.

Definition at line 906 of file SPTSearchEngine.php.

static SPTSearchEngine::QueueUpdateForItem | ( |  | $ItemOrItemId,
|  |  | $TaskPriority = `NULL`
| ) |  |
| static

Queue background update for an item.

Parameters

  mixed | $ItemOrItemId | Item to update.
  int | $TaskPriority | Priority for the task, if the default is not suitable

Definition at line 659 of file SPTSearchEngine.php.

static SPTSearchEngine::RunUpdateForItem | ( |  | $ItemId | ) |
| static

Update search index for an item.

Parameters

  int | $ItemId | Item to update.

Definition at line 697 of file SPTSearchEngine.php.

SPTSearchEngine::SearchFieldForPhrases | ( |  | $FieldId,
|  |  | $Phrase
| ) |  |

Perform phrase searching.

Parameters

  string | $FieldId | ID of field to search.
  string | $Phrase | Phrase to look for.

Returns
  array of matching ItemIds.

Definition at line 125 of file SPTSearchEngine.php.

References SearchEngine\DebugLevel(), SearchEngine\DMsg(), MetadataSchema\MDFTYPE_CONTROLLEDNAME, MetadataSchema\MDFTYPE_DATE, MetadataSchema\MDFTYPE_FILE, MetadataSchema\MDFTYPE_FLAG, MetadataSchema\MDFTYPE_IMAGE, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_OPTION, MetadataSchema\MDFTYPE_PARAGRAPH, MetadataSchema\MDFTYPE_REFERENCE, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\MDFTYPE_TREE, MetadataSchema\MDFTYPE_URL, and MetadataSchema\MDFTYPE_USER.

SPTSearchEngine::SearchFieldsForComparisonMatches | ( |  | $FieldIds,
|  |  | $Operators,
|  |  | $Values,
|  |  | $Logic
| ) |  |

Perform comparison searches.

Parameters

  array | $FieldIds | IDs of fields to search.
  array | $Operators | Search operators.
  array | $Values | Target values.
  string | $Logic | Search logic ("AND" or "OR").

Returns
  array of ItemIds that matched.

Definition at line 269 of file SPTSearchEngine.php.

References SearchEngine\DMsg(), MetadataSchema\FieldExistsInAnySchema(), MetadataSchema\GetAllSchemaIds(), MetadataSchema\MDFTYPE_CONTROLLEDNAME, MetadataSchema\MDFTYPE_DATE, MetadataSchema\MDFTYPE_FLAG, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_OPTION, MetadataSchema\MDFTYPE_PARAGRAPH, MetadataSchema\MDFTYPE_REFERENCE, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\MDFTYPE_TREE, MetadataSchema\MDFTYPE_URL, and MetadataSchema\MDFTYPE_USER.

static SPTSearchEngine::SetNumResourcesForFacets | ( |  | $NumToUse | ) |
| static

Set the number of resources used for search facets.

Parameters

  int | $NumToUse | Updated value.

Definition at line 895 of file SPTSearchEngine.php.

static SPTSearchEngine::SetUpdatePriority | ( |  | $NewPriority | ) |
| static

Set the default priority for background tasks.

Parameters

  mixed | $NewPriority | New task priority (one of ApplicationFramework::PRIORITY_*)

Definition at line 886 of file SPTSearchEngine.php.

The documentation for this class was generated from the following file:

- objects/SPTSearchEngine.php