Search/Lucene.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-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Search_Lucene
- Version
- $Id$
Package: Zend_Search_Lucene- Implements
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
GENERATION_RETRIEVE_COUNT
= 10
Generation retrieving counter
GENERATION_RETRIEVE_PAUSE
= 50
Pause between generation retrieving attempts in milliseconds
Properties
boolean $_closeDirOnExit = true
File system adapter closing option
Default valuetrue
Details- Type
- boolean
boolean $_closed = false
Signal, that index is already closed, changes are fixed and resources are cleaned up
Default valuefalse
Details- Type
- boolean
string $_defaultSearchField = null
staticDefault field name for search
Null means search through all fields
Default valuenull
Details- Type
- string
integer $_docCount = 0
Number of documents in this index.
Default value0
Details- Type
- integer
integer $_refCount = 0
Number of references to the index object
Default value0
Details- Type
- integer
array $_segmentInfos = array()
Array of Zend_Search_Lucene_Index_SegmentInfo objects for current version of index.
Default valuearray()
Details- Type
- array
integer $_termsPerQueryLimit = 1024
staticTerms per query limit
0 means no limit
Default value1024
Details- Type
- integer
Methods
commit() : void
Commit changes resulting from delete() or undeleteAll() operations.
Details- Todo
- undeleteAll processing.
find(\Zend_Search_Lucene_Search_QueryParser | string $query) : array
Performs a query against the index and returns an array
of Zend_Search_Lucene_Search_QueryHit objects.
Input is a string or Zend_Search_Lucene_Search_Query.
ParametersReturnsType | Description |
---|
array | Zend_Search_Lucene_Search_QueryHit |
ThrowsgetActualGeneration(\Zend_Search_Lucene_Storage_Directory $directory) : integer
staticGet current generation number
Returns generation number
0 means pre-2.1 index format
-1 means there are no segments files.
ParametersReturnsThrowsgetDefaultSearchField() : string
staticGet default search field.
Null means, that search is performed through all fields by default
ReturnsgetFieldNames(boolean $indexed = false) : array
Returns a list of all unique field names that exist in this index.
ParametersName | Type | Description |
---|
$indexed | boolean | |
---|
Returns getGeneration() : integer
Get generation number associated with this index instance
The same generation number in pair with document number or query string
guarantees to give the same result while index retrieving.
So it may be used for search result caching.
ReturnsgetMaxBufferedDocs() : integer
Retrieve index maxBufferedDocs option
maxBufferedDocs is a minimal number of documents required before
the buffered in-memory documents are written into a new Segment
Default value is 10
ReturnsgetMaxMergeDocs() : integer
Retrieve index maxMergeDocs option
maxMergeDocs is a largest number of documents ever merged by addDocument().
Small values (e.g., less than 10,000) are best for interactive indexing,
as this limits the length of pauses while indexing to a few seconds.
Larger values are best for batched indexing and speedier searches.
Default value is PHP_INT_MAX
ReturnsgetMergeFactor() : integer
Retrieve index mergeFactor option
mergeFactor determines how often segment indices are merged by addDocument().
With smaller values, less RAM is used while indexing,
and searches on unoptimized indices are faster,
but indexing speed is slower.
With larger values, more RAM is used during indexing,
and while searches on unoptimized indices are slower,
indexing is faster.
Thus larger values (> 10) are best for batch index creation,
and smaller values (< 10) for indices that are interactively maintained.
Default value is 10
ReturnsgetSegmentFileName(integer $generation) : string
staticGet segments file name
ParametersName | Type | Description |
---|
$generation | integer | |
---|
Returns getTermsPerQueryLimit() : integer
staticGet result set limit.
0 (default) means no limit
ReturnshasTerm(\Zend_Search_Lucene_Index_Term $term) : boolean
Returns true if index contain documents with specified term.
Is used for query optimization.
ParametersReturnsisDeleted(integer $id) : boolean
Checks, that document is deleted
ParametersName | Type | Description |
---|
$id | integer | |
---|
ReturnsThrows maxDoc() : integer
Returns one greater than the largest possible document number.
This may be used to, e.g., determine how big to allocate a structure which will have
an element for every document number in an index.
Returnsnorm(integer $id, string $fieldName) : float
Returns a normalization factor for "field, document" pair.
ParametersName | Type | Description |
---|
$id | integer | |
---|
$fieldName | string | |
---|
Returns setDefaultSearchField(string $fieldName) : void
staticSet default search field.
Null means, that search is performed through all fields by default
Default value is null
ParametersName | Type | Description |
---|
$fieldName | string | |
---|
setFormatVersion(int $formatVersion) : void
Set index format version.
Index is converted to this format at the nearest upfdate time
ParametersName | Type | Description |
---|
$formatVersion | int | |
---|
ThrowssetMaxBufferedDocs(integer $maxBufferedDocs) : void
Set index maxBufferedDocs option
maxBufferedDocs is a minimal number of documents required before
the buffered in-memory documents are written into a new Segment
Default value is 10
ParametersName | Type | Description |
---|
$maxBufferedDocs | integer | |
---|
setMaxMergeDocs(integer $maxMergeDocs) : void
Set index maxMergeDocs option
maxMergeDocs is a largest number of documents ever merged by addDocument().
Small values (e.g., less than 10,000) are best for interactive indexing,
as this limits the length of pauses while indexing to a few seconds.
Larger values are best for batched indexing and speedier searches.
Default value is PHP_INT_MAX
ParametersName | Type | Description |
---|
$maxMergeDocs | integer | |
---|
setMergeFactor( $mergeFactor) : void
Set index mergeFactor option
mergeFactor determines how often segment indices are merged by addDocument().
With smaller values, less RAM is used while indexing,
and searches on unoptimized indices are faster,
but indexing speed is slower.
With larger values, more RAM is used during indexing,
and while searches on unoptimized indices are slower,
indexing is faster.
Thus larger values (> 10) are best for batch index creation,
and smaller values (< 10) for indices that are interactively maintained.
Default value is 10
ParametersName | Type | Description |
---|
$mergeFactor | | |
---|
setResultSetLimit(integer $limit) : void
staticSet result set limit.
0 (default) means no limit
ParametersName | Type | Description |
---|
$limit | integer | |
---|
setTermsPerQueryLimit(integer $limit) : void
staticSet terms per query limit.
0 means no limit
ParametersName | Type | Description |
---|
$limit | integer | |
---|
skipTo(\Zend_Search_Lucene_Index_Term $prefix) : void
Skip terms stream up to the specified term preffix.
Prefix contains fully specified field info and portion of searched term
ParametersundeleteAll() : void
Undeletes all documents currently marked as deleted in this index.
Details- Todo
- Implementation