HumHub Documentation (unofficial)

Fuzzy extends AbstractQuery
in package

Tags
category

Zend

subpackage

Search

Table of Contents

Constants

DEFAULT_MIN_SIMILARITY  = 0.5
Default minimum similarity
MAX_CLAUSE_COUNT  = 1024
Maximum number of matched terms.

Properties

$_weight  : AbstractWeight
AbstractQuery weight
$_boost  : float
query boost factor
$_defaultPrefixLength  : int
Default non-fuzzy prefix length
$_matches  : array<string|int, mixed>
Matched terms.
$_maxDistances  : mixed
Array of precalculated max distances
$_minimumSimilarity  : float
A value between 0 and 1 to set the required similarity between the query term and the matching terms. For example, for a _minimumSimilarity of 0.5 a term of the same length as the query term is considered similar to the query term if the edit distance between both terms is less than length(term)*0.5
$_prefixLength  : int
The length of common (non-fuzzy) prefix
$_scores  : array<string|int, mixed>
Matched terms scores
$_term  : Term
Base searching term.
$_termKeys  : array<string|int, mixed>
Array of the term keys.

Methods

__construct()  : mixed
Zend_Search_Lucene_Search_Query_Wildcard constructor.
__toString()  : string
Print a query
createWeight()  : AbstractWeight
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.
getDefaultPrefixLength()  : int
Get default non-fuzzy prefix length
getQueryTerms()  : array<string|int, mixed>
Return query terms
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.
setDefaultPrefixLength()  : void
Set default non-fuzzy prefix length
_highlightMatches()  : void
Query specific matches highlighting
_initWeight()  : AbstractWeight|null
Constructs an initializes a Weight for a _top-level_query_.
_calculateMaxDistance()  : int
Calculate maximum distance for specified word length

Constants

DEFAULT_MIN_SIMILARITY

Default minimum similarity

public mixed DEFAULT_MIN_SIMILARITY = 0.5

MAX_CLAUSE_COUNT

Maximum number of matched terms.

public mixed MAX_CLAUSE_COUNT = 1024

Apache Lucene defines this limitation as boolean query maximum number of clauses: org.apache.lucene.search.BooleanQuery.getMaxClauseCount()

Properties

$_defaultPrefixLength

Default non-fuzzy prefix length

private static int $_defaultPrefixLength = 3

$_matches

Matched terms.

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

Matched terms list. It's filled during the search (rewrite operation) and may be used for search result post-processing

Array of Zend_Search_Lucene_Index_Term objects

$_maxDistances

Array of precalculated max distances

private mixed $_maxDistances = array()

keys are integers representing a word size

$_minimumSimilarity

A value between 0 and 1 to set the required similarity between the query term and the matching terms. For example, for a _minimumSimilarity of 0.5 a term of the same length as the query term is considered similar to the query term if the edit distance between both terms is less than length(term)*0.5

private float $_minimumSimilarity

$_prefixLength

The length of common (non-fuzzy) prefix

private int $_prefixLength

$_scores

Matched terms scores

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

$_termKeys

Array of the term keys.

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

Used to sort terms in alphabetical order if terms have the same socres

Methods

__construct()

Zend_Search_Lucene_Search_Query_Wildcard constructor.

public __construct(Term $term[, float $minimumSimilarity = self::DEFAULT_MIN_SIMILARITY ][, int $prefixLength = null ]) : mixed
Parameters
$term : Term
$minimumSimilarity : float = self::DEFAULT_MIN_SIMILARITY
$prefixLength : int = null
Tags
throws
InvalidArgumentException

__toString()

Print a query

public __toString() : string
Return values
string

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

getDefaultPrefixLength()

Get default non-fuzzy prefix length

public static getDefaultPrefixLength() : int
Return values
int

getQueryTerms()

Return query terms

public getQueryTerms() : array<string|int, mixed>
Tags
throws
RuntimeException
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)

Tags
throws
UnsupportedMethodCallException
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

setDefaultPrefixLength()

Set default non-fuzzy prefix length

public static setDefaultPrefixLength(int $defaultPrefixLength) : void
Parameters
$defaultPrefixLength : int

_highlightMatches()

Query specific matches highlighting

protected _highlightMatches(HighlighterInterface $highlighter) : void
Parameters
$highlighter : HighlighterInterface

Highlighter object (also contains doc for highlighting)

_calculateMaxDistance()

Calculate maximum distance for specified word length

private _calculateMaxDistance(int $prefixLength, int $termLength, int $length) : int
Parameters
$prefixLength : int
$termLength : int
$length : int
Return values
int
Loading…
On this page

Search results