HumHub Documentation (unofficial)

Phrase extends AbstractQuery
in package

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

Tags
category

Zend

subpackage

Search

Table of Contents

Properties

$_weight  : AbstractWeight
AbstractQuery weight
$_boost  : float
query boost factor
$_offsets  : array<string|int, mixed>
Term positions (relative positions of terms within the phrase).
$_resVector  : array<string|int, mixed>
Result vector.
$_slop  : int
Sets the number of other words permitted between words in query phrase.
$_terms  : array<string|int, mixed>
Terms to find.
$_termsPositions  : array<string|int, mixed>
Terms positions vectors.

Methods

__construct()  : mixed
Class constructor. Create a new prase query.
__toString()  : string
Print a query
_exactPhraseFreq()  : float
Score calculator for exact phrase queries (terms sequence is fixed)
_sloppyPhraseFreq()  : float
Score calculator for sloppy phrase queries (terms sequence is fixed)
addTerm()  : void
Adds a term to the end of the query phrase.
createWeight()  : Phrase
Constructs an appropriate Weight implementation for this query.
execute()  : void
Execute query in context of index reader It also initializes necessary internal structures
getBoost()  : 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.
getQueryTerms()  : array<string|int, mixed>
Return query terms
getSlop()  : int
Get slop
getTerms()  : array<string|int, mixed>
Returns query term
highlightMatches()  : string
Highlight matches in $inputHTML
htmlFragmentHighlightMatches()  : string
Highlight matches in $inputHTMLFragment and return it (without HTML header and body tag)
matchedDocs()  : array<string|int, mixed>
Get document ids likely matching the query
optimize()  : AbstractQuery
Optimize query in the context of specified index
reset()  : void
Reset query, so it can be reused within other queries or with other indeces
rewrite()  : AbstractQuery
Re-write query into primitive queries in the context of specified index
score()  : float
Score specified document
setBoost()  : void
Sets the boost for this query clause to $boost.
setSlop()  : void
Set slop
setWeight()  : void
Set weight for specified term
_highlightMatches()  : void
Query specific matches highlighting
_initWeight()  : AbstractWeight|null
Constructs an initializes a Weight for a _top-level_query_.

Properties

$_offsets

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

private array<string|int, mixed> $_offsets

Array of integers

$_resVector

Result vector.

private array<string|int, mixed> $_resVector = null

$_slop

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

private int $_slop

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.

$_terms

Terms to find.

private array<string|int, mixed> $_terms

Array of Zend_Search_Lucene_Index_Term objects.

$_termsPositions

Terms positions vectors.

private array<string|int, mixed> $_termsPositions = array()

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

Methods

__construct()

Class constructor. Create a new prase query.

public __construct([array<string|int, mixed> $terms = null ][, array<string|int, mixed> $offsets = null ][, string $field = null ]) : mixed
Parameters
$terms : array<string|int, mixed> = null

Terms to search Array of strings.

$offsets : array<string|int, mixed> = null

Relative term positions. Array of integers.

$field : string = null

Field to search.

Tags
throws
InvalidArgumentException

__toString()

Print a query

public __toString() : string
Return values
string

_exactPhraseFreq()

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

public _exactPhraseFreq(int $docId) : float
Parameters
$docId : int
Return values
float

_sloppyPhraseFreq()

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

public _sloppyPhraseFreq(int $docId, SearchIndexInterface $reader) : float
Parameters
$docId : int
$reader : SearchIndexInterface
Return values
float

addTerm()

Adds a term to the end of the query phrase.

public addTerm(Term $term[, int $position = null ]) : void

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

Parameters
$term : Term
$position : int = null
Tags
throws
InvalidArgumentException

getBoost()

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.

public getBoost() : float
Return values
float

getQueryTerms()

Return query terms

public getQueryTerms() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSlop()

Get slop

public getSlop() : int
Return values
int

getTerms()

Returns query term

public getTerms() : array<string|int, mixed>
Return values
array<string|int, mixed>

highlightMatches()

Highlight matches in $inputHTML

public highlightMatches(string $inputHTML[, string $defaultEncoding = '' ][, HighlighterInterface|null $highlighter = null ]) : string
Parameters
$inputHTML : string
$defaultEncoding : string = ''

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

$highlighter : HighlighterInterface|null = null
Return values
string

htmlFragmentHighlightMatches()

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

public htmlFragmentHighlightMatches(string $inputHTMLFragment[, string $encoding = 'UTF-8' ][, HighlighterInterface|null $highlighter = null ]) : string
Parameters
$inputHTMLFragment : string
$encoding : string = 'UTF-8'

Input HTML string encoding

$highlighter : HighlighterInterface|null = null
Return values
string

matchedDocs()

Get document ids likely matching the query

public matchedDocs() : array<string|int, mixed>

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

Return values
array<string|int, mixed>

reset()

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

public reset() : void

setBoost()

Sets the boost for this query clause to $boost.

public setBoost(float $boost) : void
Parameters
$boost : float

setSlop()

Set slop

public setSlop(int $slop) : void
Parameters
$slop : int

setWeight()

Set weight for specified term

public setWeight(int $num, Term $weight) : void
Parameters
$num : int
$weight : Term

        
On this page

Search results