File indexing completed on 2025-01-19 05:21:27
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Search_Lucene 0017 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0018 * @license http://framework.zend.com/license/new-bsd New BSD License 0019 * @version $Id$ 0020 */ 0021 0022 0023 /** Zend_Search_Lucene_Index_TermsStream_Interface */ 0024 // require_once 'Zend/Search/Lucene/Index/TermsStream/Interface.php'; 0025 0026 0027 /** Classes used within Zend_Search_Lucene_Interface API */ 0028 0029 /** Zend_Search_Lucene_Document */ 0030 // require_once 'Zend/Search/Lucene/Document.php'; 0031 0032 /** Zend_Search_Lucene_Index_Term */ 0033 // require_once 'Zend/Search/Lucene/Index/Term.php'; 0034 0035 /** Zend_Search_Lucene_Index_DocsFilter */ 0036 // require_once 'Zend/Search/Lucene/Index/DocsFilter.php'; 0037 0038 0039 /** 0040 * @category Zend 0041 * @package Zend_Search_Lucene 0042 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0043 * @license http://framework.zend.com/license/new-bsd New BSD License 0044 */ 0045 interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStream_Interface 0046 { 0047 /** 0048 * Get current generation number 0049 * 0050 * Returns generation number 0051 * 0 means pre-2.1 index format 0052 * -1 means there are no segments files. 0053 * 0054 * @param Zend_Search_Lucene_Storage_Directory $directory 0055 * @return integer 0056 * @throws Zend_Search_Lucene_Exception 0057 */ 0058 public static function getActualGeneration(Zend_Search_Lucene_Storage_Directory $directory); 0059 0060 /** 0061 * Get segments file name 0062 * 0063 * @param integer $generation 0064 * @return string 0065 */ 0066 public static function getSegmentFileName($generation); 0067 0068 /** 0069 * Get index format version 0070 * 0071 * @return integer 0072 */ 0073 public function getFormatVersion(); 0074 0075 /** 0076 * Set index format version. 0077 * Index is converted to this format at the nearest upfdate time 0078 * 0079 * @param int $formatVersion 0080 * @throws Zend_Search_Lucene_Exception 0081 */ 0082 public function setFormatVersion($formatVersion); 0083 0084 /** 0085 * Returns the Zend_Search_Lucene_Storage_Directory instance for this index. 0086 * 0087 * @return Zend_Search_Lucene_Storage_Directory 0088 */ 0089 public function getDirectory(); 0090 0091 /** 0092 * Returns the total number of documents in this index (including deleted documents). 0093 * 0094 * @return integer 0095 */ 0096 public function count(); 0097 0098 /** 0099 * Returns one greater than the largest possible document number. 0100 * This may be used to, e.g., determine how big to allocate a structure which will have 0101 * an element for every document number in an index. 0102 * 0103 * @return integer 0104 */ 0105 public function maxDoc(); 0106 0107 /** 0108 * Returns the total number of non-deleted documents in this index. 0109 * 0110 * @return integer 0111 */ 0112 public function numDocs(); 0113 0114 /** 0115 * Checks, that document is deleted 0116 * 0117 * @param integer $id 0118 * @return boolean 0119 * @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range 0120 */ 0121 public function isDeleted($id); 0122 0123 /** 0124 * Set default search field. 0125 * 0126 * Null means, that search is performed through all fields by default 0127 * 0128 * Default value is null 0129 * 0130 * @param string $fieldName 0131 */ 0132 public static function setDefaultSearchField($fieldName); 0133 0134 /** 0135 * Get default search field. 0136 * 0137 * Null means, that search is performed through all fields by default 0138 * 0139 * @return string 0140 */ 0141 public static function getDefaultSearchField(); 0142 0143 /** 0144 * Set result set limit. 0145 * 0146 * 0 (default) means no limit 0147 * 0148 * @param integer $limit 0149 */ 0150 public static function setResultSetLimit($limit); 0151 0152 /** 0153 * Set result set limit. 0154 * 0155 * 0 means no limit 0156 * 0157 * @return integer 0158 */ 0159 public static function getResultSetLimit(); 0160 0161 /** 0162 * Retrieve index maxBufferedDocs option 0163 * 0164 * maxBufferedDocs is a minimal number of documents required before 0165 * the buffered in-memory documents are written into a new Segment 0166 * 0167 * Default value is 10 0168 * 0169 * @return integer 0170 */ 0171 public function getMaxBufferedDocs(); 0172 0173 /** 0174 * Set index maxBufferedDocs option 0175 * 0176 * maxBufferedDocs is a minimal number of documents required before 0177 * the buffered in-memory documents are written into a new Segment 0178 * 0179 * Default value is 10 0180 * 0181 * @param integer $maxBufferedDocs 0182 */ 0183 public function setMaxBufferedDocs($maxBufferedDocs); 0184 0185 /** 0186 * Retrieve index maxMergeDocs option 0187 * 0188 * maxMergeDocs is a largest number of documents ever merged by addDocument(). 0189 * Small values (e.g., less than 10,000) are best for interactive indexing, 0190 * as this limits the length of pauses while indexing to a few seconds. 0191 * Larger values are best for batched indexing and speedier searches. 0192 * 0193 * Default value is PHP_INT_MAX 0194 * 0195 * @return integer 0196 */ 0197 public function getMaxMergeDocs(); 0198 0199 /** 0200 * Set index maxMergeDocs option 0201 * 0202 * maxMergeDocs is a largest number of documents ever merged by addDocument(). 0203 * Small values (e.g., less than 10,000) are best for interactive indexing, 0204 * as this limits the length of pauses while indexing to a few seconds. 0205 * Larger values are best for batched indexing and speedier searches. 0206 * 0207 * Default value is PHP_INT_MAX 0208 * 0209 * @param integer $maxMergeDocs 0210 */ 0211 public function setMaxMergeDocs($maxMergeDocs); 0212 0213 /** 0214 * Retrieve index mergeFactor option 0215 * 0216 * mergeFactor determines how often segment indices are merged by addDocument(). 0217 * With smaller values, less RAM is used while indexing, 0218 * and searches on unoptimized indices are faster, 0219 * but indexing speed is slower. 0220 * With larger values, more RAM is used during indexing, 0221 * and while searches on unoptimized indices are slower, 0222 * indexing is faster. 0223 * Thus larger values (> 10) are best for batch index creation, 0224 * and smaller values (< 10) for indices that are interactively maintained. 0225 * 0226 * Default value is 10 0227 * 0228 * @return integer 0229 */ 0230 public function getMergeFactor(); 0231 0232 /** 0233 * Set index mergeFactor option 0234 * 0235 * mergeFactor determines how often segment indices are merged by addDocument(). 0236 * With smaller values, less RAM is used while indexing, 0237 * and searches on unoptimized indices are faster, 0238 * but indexing speed is slower. 0239 * With larger values, more RAM is used during indexing, 0240 * and while searches on unoptimized indices are slower, 0241 * indexing is faster. 0242 * Thus larger values (> 10) are best for batch index creation, 0243 * and smaller values (< 10) for indices that are interactively maintained. 0244 * 0245 * Default value is 10 0246 * 0247 * @param integer $maxMergeDocs 0248 */ 0249 public function setMergeFactor($mergeFactor); 0250 0251 /** 0252 * Performs a query against the index and returns an array 0253 * of Zend_Search_Lucene_Search_QueryHit objects. 0254 * Input is a string or Zend_Search_Lucene_Search_Query. 0255 * 0256 * @param mixed $query 0257 * @return array Zend_Search_Lucene_Search_QueryHit 0258 * @throws Zend_Search_Lucene_Exception 0259 */ 0260 public function find($query); 0261 0262 /** 0263 * Returns a list of all unique field names that exist in this index. 0264 * 0265 * @param boolean $indexed 0266 * @return array 0267 */ 0268 public function getFieldNames($indexed = false); 0269 0270 /** 0271 * Returns a Zend_Search_Lucene_Document object for the document 0272 * number $id in this index. 0273 * 0274 * @param integer|Zend_Search_Lucene_Search_QueryHit $id 0275 * @return Zend_Search_Lucene_Document 0276 */ 0277 public function getDocument($id); 0278 0279 /** 0280 * Returns true if index contain documents with specified term. 0281 * 0282 * Is used for query optimization. 0283 * 0284 * @param Zend_Search_Lucene_Index_Term $term 0285 * @return boolean 0286 */ 0287 public function hasTerm(Zend_Search_Lucene_Index_Term $term); 0288 0289 /** 0290 * Returns IDs of all the documents containing term. 0291 * 0292 * @param Zend_Search_Lucene_Index_Term $term 0293 * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter 0294 * @return array 0295 */ 0296 public function termDocs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null); 0297 0298 /** 0299 * Returns documents filter for all documents containing term. 0300 * 0301 * It performs the same operation as termDocs, but return result as 0302 * Zend_Search_Lucene_Index_DocsFilter object 0303 * 0304 * @param Zend_Search_Lucene_Index_Term $term 0305 * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter 0306 * @return Zend_Search_Lucene_Index_DocsFilter 0307 */ 0308 public function termDocsFilter(Zend_Search_Lucene_Index_Term $term, $docsFilter = null); 0309 0310 /** 0311 * Returns an array of all term freqs. 0312 * Return array structure: array( docId => freq, ...) 0313 * 0314 * @param Zend_Search_Lucene_Index_Term $term 0315 * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter 0316 * @return integer 0317 */ 0318 public function termFreqs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null); 0319 0320 /** 0321 * Returns an array of all term positions in the documents. 0322 * Return array structure: array( docId => array( pos1, pos2, ...), ...) 0323 * 0324 * @param Zend_Search_Lucene_Index_Term $term 0325 * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter 0326 * @return array 0327 */ 0328 public function termPositions(Zend_Search_Lucene_Index_Term $term, $docsFilter = null); 0329 0330 /** 0331 * Returns the number of documents in this index containing the $term. 0332 * 0333 * @param Zend_Search_Lucene_Index_Term $term 0334 * @return integer 0335 */ 0336 public function docFreq(Zend_Search_Lucene_Index_Term $term); 0337 0338 /** 0339 * Retrive similarity used by index reader 0340 * 0341 * @return Zend_Search_Lucene_Search_Similarity 0342 */ 0343 public function getSimilarity(); 0344 0345 /** 0346 * Returns a normalization factor for "field, document" pair. 0347 * 0348 * @param integer $id 0349 * @param string $fieldName 0350 * @return float 0351 */ 0352 public function norm($id, $fieldName); 0353 0354 /** 0355 * Returns true if any documents have been deleted from this index. 0356 * 0357 * @return boolean 0358 */ 0359 public function hasDeletions(); 0360 0361 /** 0362 * Deletes a document from the index. 0363 * $id is an internal document id 0364 * 0365 * @param integer|Zend_Search_Lucene_Search_QueryHit $id 0366 * @throws Zend_Search_Lucene_Exception 0367 */ 0368 public function delete($id); 0369 0370 /** 0371 * Adds a document to this index. 0372 * 0373 * @param Zend_Search_Lucene_Document $document 0374 */ 0375 public function addDocument(Zend_Search_Lucene_Document $document); 0376 0377 /** 0378 * Commit changes resulting from delete() or undeleteAll() operations. 0379 */ 0380 public function commit(); 0381 0382 /** 0383 * Optimize index. 0384 * 0385 * Merges all segments into one 0386 */ 0387 public function optimize(); 0388 0389 /** 0390 * Returns an array of all terms in this index. 0391 * 0392 * @return array 0393 */ 0394 public function terms(); 0395 0396 /** 0397 * Undeletes all documents currently marked as deleted in this index. 0398 */ 0399 public function undeleteAll(); 0400 0401 0402 /** 0403 * Add reference to the index object 0404 * 0405 * @internal 0406 */ 0407 public function addReference(); 0408 0409 /** 0410 * Remove reference from the index object 0411 * 0412 * When reference count becomes zero, index is closed and resources are cleaned up 0413 * 0414 * @internal 0415 */ 0416 public function removeReference(); 0417 }