blueshoes php application framework and cms            core_lang
[ class tree: core_lang ] [ index: core_lang ] [ all elements ]

Class: Bs_IndexServer

Source Location: /plugins/indexserver/_Bs_Is_IndexServer.class.php

Class Overview

Bs_Object
   |
   --Bs_IndexServer

stemming: normally if you search for 'printer' then 'printers' will not be found.


Author(s):

Version:

  • 4.3.$Revision: 1.3 $ $Date: 2003/10/29 17:47:48 $

Copyright:

  • blueshoes.org

Variables

Methods


Inherited Variables

Inherited Methods

Class: Bs_Object

Bs_Object::Bs_Object()
Bs_Object::getErrors()
Basic error handling: Get *all* errors as string array from the global Bs_Error-error stack.
Bs_Object::getLastError()
Basic error handling: Get last error string from the global Bs_Error-error stack.
Bs_Object::getLastErrors()
Basic error handling: Get last errors string array from the global Bs_Error-error stack sinc last call of getLastErrors().
Bs_Object::persist()
Persists this object by serializing it and saving it to a file with unique name.
Bs_Object::setError()
Basic error handling: Push an error string on the global Bs_Error-error stack.
Bs_Object::toHtml()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::toString()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::unpersist()
Fetches an object that was persisted with persist()

Class Details

[line 79]
stemming: normally if you search for 'printer' then 'printers' will not be found.

this behavior may be desired, but i think normally you'd also want to find 'printing', 'printed', 'printers' etc.

why do we store the indexes for each table/application in separate db tables?

  • keeps the index fast(er)
  • keeps the db tables smaller
  • makes it easier to weighten the words for each table/app simpler
  • makes the overall db size bigger
terms used: sourceRecordID => the record id in the db table that needs to be indexed. it is the source of the data. queueRecordID => the record id in the todo-queue of the index server db. index => uhm. dunno how to explain that :) indexName => the name of the index.

dependencies: Bs_Db, XPath




Tags:

copyright:  blueshoes.org
version:  4.3.$Revision: 1.3 $ $Date: 2003/10/29 17:47:48 $
author:  Sam Blum <at blueshoes dot org>, andrej arn <andrej at blueshoes dot org>


[ Top ]


Class Variables

$searchStopWords =

[line 120]


Type:   mixed


[ Top ]



Class Methods


constructor Bs_IndexServer [line 124]

Bs_IndexServer Bs_IndexServer( )



[ Top ]

method cacheStopWords [line 962]

void cacheStopWords( )



[ Top ]

method cleanWord [line 1037]

void cleanWord( mixed $word, [mixed $rememberSearchStopWords = FALSE])



[ Top ]

method connectDb [line 863]

void connectDb( mixed $param)



[ Top ]

method createIndex [line 176]

bool createIndex( string $name, string $xml, [string $optimized = 'disk'])

creates a new index with the given name.

  • creates the db tables for the new index Index_{name}_relation Index_{name}_word
  • inserts the index record into table 'Indexes'.
param $optimized: 'disk' => (default) it uses a lot less disk space. (about 1/4) 'speed' => faster search. fixed length rows for the tables. the difference comes from using char fields instead of varchar.

param xml: an example of the xml definition looks like this: ----------------------------------------------------------------------- -----------------------------------------------------------------------




Tags:

return:  TRUE on success
todo:  add transactions
throws:  bs_exception
access:  public


Parameters:

string   $name   the name of the new index. it must be us-ascii [a-zA-Z0-9], *nothing* else.
string   $xml   the xml code that describes how and what to index.
string   $optimized   one of 'disk' (default) or 'speed'. see above.

[ Top ]

method dropIndex [line 272]

bool dropIndex( string $name)

drops the given index. all data will be removed (lost).

  • removes the index record in table 'Indexes'.
  • drops the db tables for the given index Index_{name}_relation Index_{name}_word
  • removes existing queued records in the table 'Queue'.




Tags:

return:  TRUE on success
todo:  add transactions
throws:  bs_exception
access:  public


Parameters:

string   $name   the name of the index. it must be us-ascii [a-zA-Z0-9], *nothing* else.

[ Top ]

method getCleanedWordString [line 1060]

void getCleanedWordString( mixed $string, [mixed $parseSearch = FALSE])



[ Top ]

method getWordArrayFromString [line 981]

void getWordArrayFromString( mixed $string)



[ Top ]

method getWordID [line 946]

void getWordID( mixed $word)



[ Top ]

method getWordProperties [line 912]

void getWordProperties( mixed $word)



[ Top ]

method indexRecord [line 728]

boolean; indexRecord( [string $dbName = ""], [string $tableName = ""], [int $recordID = 0])

this function (re)indexes a record.

if the record was already indexed, the old indexes are removed.




Tags:

return:  true on success, false on failure
version:  1.0


Parameters:

string   $dbName   dbName; the name of the database where the record is
string   $tableName   tableName; the name of the table where the record is
int   $recordID   recordID; the id of the record

[ Top ]

method indexRecord [line 706]

void indexRecord( mixed $name, mixed $recordID)



[ Top ]

method isStopWord [line 974]

void isStopWord( mixed $word)



[ Top ]

method parseSearchInput [line 1100]

void parseSearchInput( mixed $string)



[ Top ]

method queueAdd [line 349]

bool queueAdd( string $name, int $sourceRecordID, [mixed $todo = 'a'])

adds a record to the index-todo-queue.

the record may be added to be (re)indexed or to be removed from the index.

behavior of adding:

  • if this record is already in the queue and waiting to be (re)indexed, and you want to index it again, then it won't be added again. it would make no sense.
  • if this record is already in the queue and waiting to be (re)indexed, and you want to remove it from the index (probably because the record has been deleted), then the existing queue-entry will be removed. it is of no use anymore.
  • if the record is waiting to be removed from the index, and you want to queue another delete order, then it won't be added. would make no sense to remove twice.
  • it is *theoretically* possible that a record has been removed from the table and it is marked here to be removed from the index aswell. now in the meantime a record has been added with exactly the same record id. and this one gets added here to the queue. in this case we have to keep the remove-index command, and it will have to be executed before the new record is indexed. this case really is not usual since databases normally don't allow you to use an id when inserting a record that has been in use before. but it still may happen.
overview: +-----------------+------------+---------+-------------+ | existing entry | new entry | accept? | new entries | +-----------------+------------+---------+-------------+ | add | add | no | add | | add | remove | yes | remove | | remove | add | yes | remove add | | remove | remove | no | remove | | remove add | add | no | remove add | | remove add | remove | yes | remove | +-----------------+------------+---------+-------------+




Tags:

return:  TRUE if it has been added, FALSE if it has not been added (failed, already listed, whatever).
see:  Bs_IndexServer::queueRemove()
access:  public


Parameters:

string   $name   the name of the index.
int   $sourceRecordID   the record that you want to have indexed.

[ Top ]

method queueRemove [line 413]

int queueRemove( mixed $queueRecordID)

removes a record from the index-todo-queue.



Tags:

return:  the number of deleted records
see:  Bs_IndexServer::queueAdd()
throws:  bs_exception on error, bool FALSE if just the count of the deleted records failed.
access:  public


Parameters:

mixed   $queueRecordID   the record id from the queue table that you want to delete. an int or a vector filled with integers.

[ Top ]

method removeRecordIndex [line 713]

void removeRecordIndex( mixed $name, mixed $recordID)



[ Top ]

method search [line 487]

void search( [mixed $searchInput = ""], [mixed $preWhere = ""])



[ Top ]

method searchQueryHelper [line 686]

void searchQueryHelper( mixed $query, mixed $points)



[ Top ]

method treatSpecialChars [line 1001]

void treatSpecialChars( [mixed $string = ""], [mixed $replaceWith = " "], [mixed $allowedSpecialCharsArray = ""])



[ Top ]

method uniqueArray [line 1151]

void uniqueArray( mixed $array)



[ Top ]


Documentation generated on Mon, 29 Dec 2003 21:16:41 +0100 by phpDocumentor 1.2.3