Class search

Description

The search class is an object which can be assigned search terms, can execute a search, and can contain search hits having executed a seach.

NOTE: This is a virtual class which is expected to be used by a child class which implements a particular search mechanism eg: swish++ or database query searching. As such the execute() method does nothing and must be over-ridden in the child classes implementing searching.

Located in /search-defs.php (line 113)


	
			
Direct descendents
Class Description
 class db_search DB Search class This class inherits the functionality of the generic 'search' class. It extends it to implement a database search.
 class lucene_connection The lucene connection class
 class swish_search The swish search class
 class searchengine_connection The SearchEngine connection class
Variable Summary
 mixed $date_end
 mixed $date_start
 mixed $executed
 mixed $hit
 mixed $max_results
 mixed $query
 mixed $searchterm
 mixed $title
Method Summary
 search search ([string $title = "Search Results"])
 void clear_daterange ()
 void clear_search ()
 void does_not_match (string $term, [string $id = ""])
 boolean has_daterange ()
 integer hitcount ()
 void initialise ()
 void match ([string $term = ""], [integer $op = "OR"], [string $id = ""])
 void may_match (string $term, [string $id = ""])
 void must_match (string $term, [string $id = ""])
 void reset_search ()
 void set_daterange ([string $start = false], [string $end = false], [mixed $date_fieldname = ""])
 void set_maxresults (integer $max)
 void set_skipresults (integer $skip)
 integer termcount ()
Variables
mixed $date_end = false (line 132)

End date range for search (false means undefined). This

mixed $date_fieldname = "" (line 134)

Name of the field to which daterange should be applied

mixed $date_start = false (line 129)

Start date range for search (false means undefined). This

mixed $executed = false (line 136)

Whether we have run a query

mixed $hit = array() (line 120)

Array of hits returned. Each element of this array is

mixed $max_results = 25 (line 124)

Maximum results to return in query

mixed $query = "" (line 117)

Query string container

mixed $searchterm = array() (line 122)

Array of search terms to match

mixed $skip_results = 0 (line 126)

No. of results to skip in query (for paging)

mixed $title = "" (line 115)

Title for heading of output

Methods
Constructor search (line 143)

Constructor Create a new search.

search search ([string $title = "Search Results"])
  • string $title: Title/description for this search
clear_daterange (line 170)

Clear the date range for the search. Makes sure that the search will not be filtered by a date restriction.

void clear_daterange ()
clear_search (line 332)

Clear the search terms and any stored hits.

void clear_search ()
does_not_match (line 263)

Define a search term which the search must not match to succeed.

void does_not_match (string $term, [string $id = ""])
  • string $term: Search term text to match.
  • string $id: An optional ID to associate with this search term.
has_daterange (line 193)

Return true if at least one of our dates is set.

  • return: True if a date range is in effect.
boolean has_daterange ()
hitcount (line 186)

Return count of hits present in this search.

  • return: Number of hits we got.
integer hitcount ()
initialise (line 324)

Initialise everything about the search.

Initialise to a state which is the same as when the object is instantiated.

void initialise ()
match (line 233)

Add a new search term to match. Search terms can be a single word or compound patterns, Each time one of these is added, it has an operator associated with it - whether this term is a "may have" (OR), or a "must have" (AND) term.

Visualize these terms as self-contained statements, with brackets around each end, and which are joined to others by the given operator to make the whole query.

void match ([string $term = ""], [integer $op = "OR"], [string $id = ""])
  • string $term: Search term text to match.
  • integer $op: Joining operator: 'AND', 'OR', 'NOT, 'AND NOT'.
  • string $id: An optional ID to associate with this search term.

Redefined in descendants as:
  • lucene_search::match() : Add a new search term to match. Search terms can be a single word or compound patterns, Each time one of these is added, it has an operator associated with it - whether this term is a "may have" (OR), or a "must have" (AND) term.
  • searchengine_search::match() : Add a new search term to match. Search terms can be a single word or compound patterns, Each time one of these is added, it has an operator associated with it - whether this term is a "may have" (OR), or a "must have" (AND) term.
may_match (line 254)

Define a search term which the search may or may not match.

void may_match (string $term, [string $id = ""])
  • string $term: Search term text to match.
  • string $id: An optional ID to associate with this search term.
must_match (line 245)

Define a search term which the search must match to succeed.

void must_match (string $term, [string $id = ""])
  • string $term: Search term text to match.
  • string $id: An optional ID to associate with this search term.
reset_search (line 344)

Reset search to null query and not executed status.

void reset_search ()
set_daterange (line 156)

Set date range Set the date range for the search. This is just recording the given date information for use by child classes of this one. We do not even care what the format of the dates is. They are just stored.

void set_daterange ([string $start = false], [string $end = false], [mixed $date_fieldname = ""])
  • string $start: Start date for search
  • string $end: End date for search
set_maxresults (line 202)

Set maximum results Sets the maximum results to return from the search.

void set_maxresults (integer $max)
  • integer $max: Maximum hits to return
set_skipresults (line 216)

Set skip results

Sets the number of results to skip in the query. Eg. If this is set to 15, then the first 15 results of the query will be skipped before returning results. This can be used as a method of paging a query which returns a large number of results..

void set_skipresults (integer $skip)
  • integer $skip: Number of initial hits to skip
termcount (line 179)

Return count of searchterms present in this search.

  • return: Number of search terms we have currently.
integer termcount ()

Documentation generated by phpDocumentor 1.3.0RC3