Class lucene_search

Description

The lucene search class

This class inherits the functionality of the generic 'search' class. It extends it to implement a LUCENE search. Use the methods in this class as the mainstay in implementing queries of content from Lucene. Most methods, such as match(), matchfield(), matchrange() etc. store the requirement in the class for subsequent building using the set_*() methods of the lucene classes to set the relevant fields. This is only done when you call execute(), and the query is built from all the composite terms you have added via match() et al.

Located in /lucene-defs.php (line 1263)

search
   |
   --lucene_connection
      |
      --lucene_msg
         |
         --lucene_message
            |
            --lucene_querymsg
               |
               --lucene_search
Method Summary
 lucene_search lucene_search ([string $application = "?"], [string $host = ""], [string $port = ""])
 void does_not_matchfield (string $fieldname, string $fieldvalue, [string $id = ""], [numeric $boost = ""])
 void execute ([integer $timeoutsecs = ""])
 void match (string $term, [integer $op = "OR"], [string $id = ""], [numeric $boost = ""])
 void matchfield (string $fieldname, mixed $fieldvalue, [string $op = "OR"], [string $id = ""], [numeric $boost = ""])
 void matchrange (string $fromvalue, string $tovalue, string $fieldname)
 void may_matchfield (string $fieldname, string $fieldvalue, [string $id = ""], [numeric $boost = ""])
 void must_matchfield (string $fieldname, string $fieldvalue, [string $id = ""], [numeric $boost = ""])
Variables
Methods
Constructor lucene_search (line 1272)

Constructor

Create a new lucene search

lucene_search lucene_search ([string $application = "?"], [string $host = ""], [string $port = ""])
  • string $application: Application name/domain name for searching in
  • string $host: Hostname or IP of Lucene server
  • string $port: Port of Lucene server
does_not_matchfield (line 1405)

Add search term: must not match a field value.

This is used to add a search term which defines the value that a given field must not contain for the search to succeed.

void does_not_matchfield (string $fieldname, string $fieldvalue, [string $id = ""], [numeric $boost = ""])
  • string $fieldname: Name of field
  • string $fieldvalue: Value of field to match
  • string $id: Optional identity tag for this term
  • numeric $boost: Boost factor. Can be a fraction eg. 0.2, or integer 1,2,3..
execute (line 1416)

Execute the search Here we execute a lucene search, overriding the method in the parent class. This involves building the query string, sending it to the Lucene server, and receiving the search results back.

void execute ([integer $timeoutsecs = ""])
  • integer $timeoutsecs: Override for timeout in seconds
match (line 1296)

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.

NB: This method overrides the parent method in order to ensure that all boolean logic terms are in upper case as Lucene requires.

void match (string $term, [integer $op = "OR"], [string $id = ""], [numeric $boost = ""])
  • 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.
  • numeric $boost: Boost factor. Can be a fraction eg. 0.2, or integer 1,2,3..

Redefinition of:
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.
matchfield (line 1317)

Add search term to match a field value.

This is used to add a search term which defines the value that a given field may or may not contain for the search to succeed. For adding terms which are 'free' (as a user might type into a search box for example) then you can use the match() method which this class inherits from the search class.

void matchfield (string $fieldname, mixed $fieldvalue, [string $op = "OR"], [string $id = ""], [numeric $boost = ""])
  • string $fieldname: Name of field to reference in the index
  • mixed $fieldvalue: Value or array of values, for field to match
  • string $op: Operator to join this term to others in the query
  • string $id: Optional identity tag for this term
  • numeric $boost: Boost factor. Can be a fraction eg. 0.2, or integer 1,2,3..
matchrange (line 1364)

Add search term to match a field value range.

This is used to add a search term which defines the range of values that a given field may or may not contain for the search to succeed. NB: This method is always a must match (implied AND) search term. In other words the search is always restricted/refined by it.

void matchrange (string $fromvalue, string $tovalue, string $fieldname)
  • string $fromvalue: Lower range value of field to match
  • string $tovalue: Upper range value of field to match
  • string $fieldname: Name of field, defaulted to 'Text'
may_matchfield (line 1392)

Add search term: may match a field value.

This is used to add a search term which defines the value that a given field may contain for the search to succeed.

void may_matchfield (string $fieldname, string $fieldvalue, [string $id = ""], [numeric $boost = ""])
  • string $fieldname: Name of field
  • string $fieldvalue: Value of field to match
  • string $id: Optional identity tag for this term
  • numeric $boost: Boost factor. Can be a fraction eg. 0.2, or integer 1,2,3..
must_matchfield (line 1379)

Add search term: must match a field value.

This is used to add a search term which defines the value that a given field must contain for the search to succeed.

void must_matchfield (string $fieldname, string $fieldvalue, [string $id = ""], [numeric $boost = ""])
  • string $fieldname: Name of field
  • string $fieldvalue: Value of field to match
  • string $id: Optional identity tag for this term
  • numeric $boost: Boost factor. Can be a fraction eg. 0.2, or integer 1,2,3..

Inherited Methods

Inherited From lucene_querymsg

 lucene_querymsg::lucene_querymsg()
 lucene_querymsg::send()
 lucene_querymsg::set_query()

Inherited From lucene_message

 lucene_message::lucene_message()
 lucene_message::define_field()
 lucene_message::set_first()
 lucene_message::set_limit()
 lucene_message::set_range()
 lucene_message::set_returnfields()
 lucene_message::set_sortorder()
 lucene_message::set_stopwords()

Inherited From lucene_msg

 lucene_msg::lucene_msg()
 lucene_msg::add_field()
 lucene_msg::add_xmltag()
 lucene_msg::clear()
 lucene_msg::send()
 lucene_msg::set_application()
 lucene_msg::set_domain()

Inherited From lucene_connection

 lucene_connection::lucene_connection()
 lucene_connection::send()
 lucene_connection::set_timeout()

Inherited From search

 search::search()
 search::clear_daterange()
 search::clear_search()
 search::does_not_match()
 search::has_daterange()
 search::hitcount()
 search::initialise()
 search::match()
 search::may_match()
 search::must_match()
 search::reset_search()
 search::set_daterange()
 search::set_maxresults()
 search::set_skipresults()
 search::termcount()

Documentation generated by phpDocumentor 1.3.0RC3