![]() |
Xataface
2.0alpha2
Xataface Application Framework
|
Public Member Functions | |
| createIndexTable () | |
| indexRecord (&$record, $lang='*') | |
| indexFoundRecords ($query, $lang='*') | |
| buildIndex ($tables=null, $lang='*', $clear=true) | |
| isTableIndexable ($tablename) | |
| _cmp_words_by_length ($a, $b) | |
| find ($query, $returnMetadata=false, $lang=null) | |
A class that indexes records in a dataface application.
Usage:
$index = new Dataface_Index();
$index->buildIndex(); // Clears the index and builds it anew $index->buildIndex(array('people')); // indexes records in the people table only (but erases entire index $index->buildIndex(array('people'), '*',false); // indexes reords in the people table for all languages, but doesn't // erase existing index for other tables.
// Suppose we already have a record that we want to index. $record =& df_get_record_by_id('people?personid=10'); $index->indexRecord($record); // indexes record in all languages. $index->indexRecord($record, null); //indexes record in current language. $index->indexRecord($record, 'en'); // indexes record in english only.
$index->indexFoundRecords(array('-table'=>'people', 'personid'=>'>10'));
$results = $index->find(array('-search'=>"My search words")); foreach ($results as $result){ echo $result['record_id']; echo $result['record_url']; echo $result['record_title']; echo $result['record_description']; echo $result['relevance']; }
| find | ( | $query, | |
$returnMetadata = false, |
|||
$lang = null |
|||
| ) |
| indexRecord | ( | & | $record, |
$lang = '*' |
|||
| ) |
Indexes a record so that it is searchable in the index. If the index table does not exist yet, this will create it.
| Dataface_Record | &$record | The record to be indexed. |
| string | $lang | The 2-digit language code representing the language that this record is stored in. |
1.8.1.2