Xataface 2.0
Xataface Application Framework
Public Member Functions
Dataface_Index Class Reference

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)

Detailed Description

A class that indexes records in a dataface application.

Usage:

Building entire index

$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.

Indexing single record

// 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.

Indexing based on a query or found set

$index->indexFoundRecords(array('-table'=>'people', 'personid'=>'>10'));

Performing queries on the index

$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']; }

Definition at line 46 of file Index.php.


Member Function Documentation

_cmp_words_by_length ( a,
b 
)

Definition at line 209 of file Index.php.

buildIndex ( tables = null,
lang = '*',
clear = true 
)

Definition at line 158 of file Index.php.

createIndexTable ( )

Creates the index table.

Definition at line 51 of file Index.php.

find ( query,
returnMetadata = false,
lang = null 
)

This will find , in relevance sorted order the records from the index.

Parameters:
array$queryQuery array. Important parameters are '-search', '-skip', and '-limit'
Returns:
array

Definition at line 220 of file Index.php.

indexFoundRecords ( query,
lang = '*' 
)

Definition at line 143 of file Index.php.

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.

Parameters:
Dataface_Record&$recordThe record to be indexed.
string$langThe 2-digit language code representing the language that this record is stored in.

Definition at line 79 of file Index.php.

isTableIndexable ( tablename)

Definition at line 180 of file Index.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations