category Zend
package Zend_Search_Lucene
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_Search_Lucene_Index_TermsStream_Interface

 Methods

Adds a document to this index.

addDocument(\Zend_Search_Lucene_Document $document) 

Parameters

$document

\Zend_Search_Lucene_Document

Commit changes resulting from delete() or undeleteAll() operations.

commit() 

Returns the total number of documents in this index (including deleted documents).

count() : integer

Returns

integer

Deletes a document from the index.

delete(integer|\Zend_Search_Lucene_Search_QueryHit $id) 

$id is an internal document id

Parameters

$id

integer\Zend_Search_Lucene_Search_QueryHit

Exceptions

\Zend_Search_Lucene_Exception

Returns the number of documents in this index containing the $term.

docFreq(\Zend_Search_Lucene_Index_Term $term) : integer

Parameters

$term

\Zend_Search_Lucene_Index_Term

Returns

integer

Performs a query against the index and returns an array of Zend_Search_Lucene_Search_QueryHit objects.

find(mixed $query) : array

Input is a string or Zend_Search_Lucene_Search_Query.

Parameters

$query

mixed

Exceptions

\Zend_Search_Lucene_Exception

Returns

arrayZend_Search_Lucene_Search_QueryHit

Get current generation number

getActualGeneration(\Zend_Search_Lucene_Storage_Directory $directory) : integer
Static

Returns generation number 0 means pre-2.1 index format -1 means there are no segments files.

Parameters

$directory

\Zend_Search_Lucene_Storage_Directory

Exceptions

\Zend_Search_Lucene_Exception

Returns

integer

Get default search field.

getDefaultSearchField() : string
Static

Null means, that search is performed through all fields by default

Returns

string

Returns the Zend_Search_Lucene_Storage_Directory instance for this index.

getDirectory() : \Zend_Search_Lucene_Storage_Directory

Returns

\Zend_Search_Lucene_Storage_Directory

Returns a Zend_Search_Lucene_Document object for the document number $id in this index.

getDocument(integer|\Zend_Search_Lucene_Search_QueryHit $id) : \Zend_Search_Lucene_Document

Parameters

$id

integer\Zend_Search_Lucene_Search_QueryHit

Returns

\Zend_Search_Lucene_Document

Returns a list of all unique field names that exist in this index.

getFieldNames(boolean $indexed = false) : array

Parameters

$indexed

boolean

Returns

array

Get index format version

getFormatVersion() : integer

Returns

integer

Retrieve index maxBufferedDocs option

getMaxBufferedDocs() : integer

maxBufferedDocs is a minimal number of documents required before the buffered in-memory documents are written into a new Segment

Default value is 10

Returns

integer

Retrieve index maxMergeDocs option

getMaxMergeDocs() : integer

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

Returns

integer

Retrieve index mergeFactor option

getMergeFactor() : integer

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

Returns

integer

Set result set limit.

getResultSetLimit() : integer
Static

0 means no limit

Returns

integer

Get segments file name

getSegmentFileName(integer $generation) : string
Static

Parameters

$generation

integer

Returns

string

Retrive similarity used by index reader

getSimilarity() : \Zend_Search_Lucene_Search_Similarity

Returns

\Zend_Search_Lucene_Search_Similarity

Returns true if any documents have been deleted from this index.

hasDeletions() : boolean

Returns

boolean

Returns true if index contain documents with specified term.

hasTerm(\Zend_Search_Lucene_Index_Term $term) : boolean

Is used for query optimization.

Parameters

$term

\Zend_Search_Lucene_Index_Term

Returns

boolean

Checks, that document is deleted

isDeleted(integer $id) : boolean

Parameters

$id

integer

Exceptions

\Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range

Returns

boolean

Returns one greater than the largest possible document number.

maxDoc() : integer

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.

Returns

integer

Returns a normalization factor for "field, document" pair.

norm(integer $id, string $fieldName) : float

Parameters

$id

integer

$fieldName

string

Returns

float

Returns the total number of non-deleted documents in this index.

numDocs() : integer

Returns

integer

Optimize index.

optimize() 

Merges all segments into one

Set default search field.

setDefaultSearchField(string $fieldName) 
Static

Null means, that search is performed through all fields by default

Default value is null

Parameters

$fieldName

string

Set index format version.

setFormatVersion(integer $formatVersion) 

Index is converted to this format at the nearest upfdate time

Parameters

$formatVersion

integer

Exceptions

\Zend_Search_Lucene_Exception

Set index maxBufferedDocs option

setMaxBufferedDocs(integer $maxBufferedDocs) 

maxBufferedDocs is a minimal number of documents required before the buffered in-memory documents are written into a new Segment

Default value is 10

Parameters

$maxBufferedDocs

integer

Set index maxMergeDocs option

setMaxMergeDocs(integer $maxMergeDocs) 

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

Parameters

$maxMergeDocs

integer

Set index mergeFactor option

setMergeFactor($mergeFactor) 

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

Parameters

$mergeFactor

Set result set limit.

setResultSetLimit(integer $limit) 
Static

0 (default) means no limit

Parameters

$limit

integer

Returns IDs of all the documents containing term.

termDocs(\Zend_Search_Lucene_Index_Term $term, \Zend_Search_Lucene_Index_DocsFilter|null $docsFilter = null) : array

Parameters

$term

\Zend_Search_Lucene_Index_Term

$docsFilter

\Zend_Search_Lucene_Index_DocsFilternull

Returns

array

Returns documents filter for all documents containing term.

termDocsFilter(\Zend_Search_Lucene_Index_Term $term, \Zend_Search_Lucene_Index_DocsFilter|null $docsFilter = null) : \Zend_Search_Lucene_Index_DocsFilter

It performs the same operation as termDocs, but return result as Zend_Search_Lucene_Index_DocsFilter object

Parameters

$term

\Zend_Search_Lucene_Index_Term

$docsFilter

\Zend_Search_Lucene_Index_DocsFilternull

Returns

\Zend_Search_Lucene_Index_DocsFilter

Returns an array of all term freqs.

termFreqs(\Zend_Search_Lucene_Index_Term $term, \Zend_Search_Lucene_Index_DocsFilter|null $docsFilter = null) : integer

Return array structure: array( docId => freq, ...)

Parameters

$term

\Zend_Search_Lucene_Index_Term

$docsFilter

\Zend_Search_Lucene_Index_DocsFilternull

Returns

integer

Returns an array of all term positions in the documents.

termPositions(\Zend_Search_Lucene_Index_Term $term, \Zend_Search_Lucene_Index_DocsFilter|null $docsFilter = null) : array

Return array structure: array( docId => array( pos1, pos2, ...), ...)

Parameters

$term

\Zend_Search_Lucene_Index_Term

$docsFilter

\Zend_Search_Lucene_Index_DocsFilternull

Returns

array

Returns an array of all terms in this index.

terms() : array

Returns

array

Undeletes all documents currently marked as deleted in this index.

undeleteAll()