Login   Register  
PHP Classes
elePHPant
Icontem

File: Documentation.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Richard Carson  >  Ssearch  >  Documentation.txt  >  Download  
File: Documentation.txt
Role: Documentation
Content type: text/plain
Description: Documentation
Class: Ssearch
Search and rank text results in an array
Author: By
Last change:
Date: 2011-01-08 19:47
Size: 1,264 bytes
 

Contents

Class file image Download
Sphinx Search for database driven websites
Copyright 2010, Richard Carson (rscarson@rogers.com) 
sphinxgaming.com
This software is available under the GPL

This search method uses a regular expression search of a character tree, and gives each object a weighted score. 
Scores are determined by string length, where matches of 1 char is 1 point, 2 chars are 10 points, 3 chars are 100 points, etc
A value of 1001, or 101 is a good starting point
Objects below the minimum score are dropped, and the rest are sorted by score.
Please note that depending on the minimum score, some queries may be too short. 
Use the GetShortestGood method to determine the minimum length a query string must have
The dataset must be in the form of:
Dataset(
	object
	(
		string
		string
	}
	object
	(
		string
		string
		string
	)
)

SetScore($score) //Set the minimum score
GetScore() //Get the current minimum score
SetData($Dataset, $checkit=true) //Set the dataset, verification of dataset formatting is optional, and on by default
GetData($index=-1) //Get the current dataset, or the object at index
Search($Query, $debug=false) //Perform a search, debug mode is available.
GetShortestGood() //Get the shortest query length that can return results