API Documentation

Search/Lucene/Search/Query/Phrase.php

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

category
Zend  
copyright
Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)  
license
New BSD License  
package
Zend_Search_Lucene  
subpackage
Search  
version
$Id: Phrase.php 23775 2011-03-01 17:25:24Z ralph $  

\Zend_Search_Lucene_Search_Query_Phrase

A Query that matches documents containing a particular sequence of terms.

Extends from
\Zend_Search_Lucene_Search_Query
category
Zend  
copyright
Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)  
license
New BSD License  
package
Zend_Search_Lucene  
subpackage
Search  

Properties

Propertyprivatearray  $_offsets= ''

Term positions (relative positions of terms within the phrase).

Array of integers

Details
Type
array
Propertyprivatearray  $_resVector= 'null'

Result vector.

Default valuenullDetails
Type
array
Propertyprivateinteger  $_slop= ''

Sets the number of other words permitted between words in query phrase.

If zero, then this is an exact phrase search. For larger values this works like a WITHIN or NEAR operator.

The slop is in fact an edit-distance, where the units correspond to moves of terms in the query phrase out of position. For example, to switch the order of two words requires two moves (the first move places the words atop one another), so to permit re-orderings of phrases, the slop must be at least two. More exact matches are scored higher than sloppier matches, thus search results are sorted by exactness.

The slop is zero by default, requiring exact matches.

Details
Type
integer
Propertyprivatearray  $_terms= ''

Terms to find.

Array of Zend_Search_Lucene_Index_Term objects.

Details
Type
array
Propertyprivatearray  $_termsPositions= 'array'

Terms positions vectors.

Array of Arrays: term1Id => (docId => array( pos1, pos2, ... ), ...) term2Id => (docId => array( pos1, pos2, ... ), ...)

Default valuearrayDetails
Type
array

Methods

methodpublic__construct( array $terms = null, array $offsets = null, string $field = null ) : void

Class constructor. Create a new prase query.

Parameters
Name Type Description
$terms array Terms to search Array of strings.
$offsets array Relative term positions. Array of integers.
$field string Field to search.
Throws
Exception Description
\Zend_Search_Lucene_Exception
methodpublic__toString( ) : string

Print a query

Returns
Type Description
string
methodpublic_exactPhraseFreq( integer $docId ) : float

Score calculator for exact phrase queries (terms sequence is fixed)

Parameters
Name Type Description
$docId integer
Returns
Type Description
float
methodprotected_highlightMatches( \Zend_Search_Lucene_Search_Highlighter_Interface $highlighter ) : void

Query specific matches highlighting

Parameters
Name Type Description
$highlighter \Zend_Search_Lucene_Search_Highlighter_Interface

Highlighter object (also contains doc for highlighting)

methodprotected_initWeight( \Zend_Search_Lucene_Interface $reader ) : void

Constructs an initializes a Weight for a _top-level_query_.

Inherited from: \Zend_Search_Lucene_Search_Query::_initWeight()
Parameters
Name Type Description
$reader \Zend_Search_Lucene_Interface
methodpublic_sloppyPhraseFreq( integer $docId, \Zend_Search_Lucene_Interface $reader ) : float

Score calculator for sloppy phrase queries (terms sequence is fixed)

Parameters
Name Type Description
$docId integer
$reader \Zend_Search_Lucene_Interface
Returns
Type Description
float
methodpublicaddTerm( \Zend_Search_Lucene_Index_Term $term, integer $position = null ) : void

Adds a term to the end of the query phrase.

The relative position of the term is specified explicitly or the one immediately after the last term added.

Parameters
Name Type Description
$term \Zend_Search_Lucene_Index_Term
$position integer
methodpubliccreateWeight( \Zend_Search_Lucene_Interface $reader ) : \Zend_Search_Lucene_Search_Weight

Constructs an appropriate Weight implementation for this query.

Parameters
Name Type Description
$reader \Zend_Search_Lucene_Interface
Returns
Type Description
\Zend_Search_Lucene_Search_Weight
methodpublicexecute( \Zend_Search_Lucene_Interface $reader, \Zend_Search_Lucene_Index_DocsFilter|null $docsFilter = null ) : void

Execute query in context of index reader It also initializes necessary internal structures

Query specific implementation

Parameters
Name Type Description
$reader \Zend_Search_Lucene_Interface
$docsFilter \Zend_Search_Lucene_Index_DocsFilter|null
methodpublicgetBoost( ) : float

Gets the boost for this clause. Documents matching this clause will (in addition to the normal weightings) have their score multiplied by boost. The boost is 1.0 by default.

Inherited from: \Zend_Search_Lucene_Search_Query::getBoost()
Returns
Type Description
float
methodpublicgetQueryTerms( ) : array

Return query terms

Returns
Type Description
array
methodpublicgetSlop( ) : integer

Get slop

Returns
Type Description
integer
methodpublicgetTerms( ) : array

Returns query term

Returns
Type Description
array
methodpublichighlightMatches( string $inputHTML, string $defaultEncoding, \Zend_Search_Lucene_Search_Highlighter_Interface|null $highlighter = null ) : string

Highlight matches in $inputHTML

Inherited from: \Zend_Search_Lucene_Search_Query::highlightMatches()
Parameters
Name Type Description
$inputHTML string
$defaultEncoding string

HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag.

$highlighter \Zend_Search_Lucene_Search_Highlighter_Interface|null
Returns
Type Description
string
methodpublichtmlFragmentHighlightMatches( string $inputHtmlFragment, string $encoding = UTF-8, \Zend_Search_Lucene_Search_Highlighter_Interface|null $highlighter = null ) : string

Highlight matches in $inputHtmlFragment and return it (without HTML header and body tag)

Inherited from: \Zend_Search_Lucene_Search_Query::htmlFragmentHighlightMatches()
Parameters
Name Type Description
$inputHtmlFragment string
$encoding string Input HTML string encoding
$highlighter \Zend_Search_Lucene_Search_Highlighter_Interface|null
Returns
Type Description
string
methodpublicmatchedDocs( ) : array

Get document ids likely matching the query

It's an array with document ids as keys (performance considerations)

Returns
Type Description
array
methodpublicoptimize( \Zend_Search_Lucene_Interface $index ) : \Zend_Search_Lucene_Search_Query

Optimize query in the context of specified index

Parameters
Name Type Description
$index \Zend_Search_Lucene_Interface
Returns
Type Description
\Zend_Search_Lucene_Search_Query
methodpublicreset( ) : void

Reset query, so it can be reused within other queries or with other indeces

Inherited from: \Zend_Search_Lucene_Search_Query::reset()
methodpublicrewrite( \Zend_Search_Lucene_Interface $index ) : \Zend_Search_Lucene_Search_Query

Re-write query into primitive queries in the context of specified index

Parameters
Name Type Description
$index \Zend_Search_Lucene_Interface
Returns
Type Description
\Zend_Search_Lucene_Search_Query
methodpublicscore( integer $docId, \Zend_Search_Lucene_Interface $reader ) : float

Score specified document

Parameters
Name Type Description
$docId integer
$reader \Zend_Search_Lucene_Interface
Returns
Type Description
float
methodpublicsetBoost( float $boost ) : void

Sets the boost for this query clause to $boost.

Inherited from: \Zend_Search_Lucene_Search_Query::setBoost()
Parameters
Name Type Description
$boost float
methodpublicsetSlop( integer $slop ) : void

Set slop

Parameters
Name Type Description
$slop integer
methodpublicsetWeight( integer $num, \Zend_Search_Lucene_Search_Weight_Term $weight ) : void

Set weight for specified term

Parameters
Name Type Description
$num integer
$weight \Zend_Search_Lucene_Search_Weight_Term
Documentation was generated by DocBlox 0.13.3.