7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
16 * @package Zend_Search_Lucene
17 * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
18 * @license http://framework.zend.com/license/new-bsd New BSD License
24 * @package Zend_Search_Lucene
25 * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
26 * @license http://framework.zend.com/license/new-bsd New BSD License
28 interface Zend_Search_Lucene_Interface
31 * Returns the Zend_Search_Lucene_Storage_Directory instance for this index.
33 * @return Zend_Search_Lucene_Storage_Directory
35 public function getDirectory();
38 * Returns the total number of documents in this index (including deleted documents).
42 public function count();
45 * Returns one greater than the largest possible document number.
46 * This may be used to, e.g., determine how big to allocate a structure which will have
47 * an element for every document number in an index.
51 public function maxDoc();
54 * Returns the total number of non-deleted documents in this index.
58 public function numDocs();
61 * Checks, that document is deleted
65 * @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range
67 public function isDeleted($id);
70 * Set default search field.
72 * Null means, that search is performed through all fields by default
74 * Default value is null
76 * @param string $fieldName
78 public static function setDefaultSearchField($fieldName);
81 * Get default search field.
83 * Null means, that search is performed through all fields by default
87 public static function getDefaultSearchField();
90 * Retrieve index maxBufferedDocs option
92 * maxBufferedDocs is a minimal number of documents required before
93 * the buffered in-memory documents are written into a new Segment
99 public function getMaxBufferedDocs();
102 * Set index maxBufferedDocs option
104 * maxBufferedDocs is a minimal number of documents required before
105 * the buffered in-memory documents are written into a new Segment
107 * Default value is 10
109 * @param integer $maxBufferedDocs
111 public function setMaxBufferedDocs($maxBufferedDocs);
114 * Retrieve index maxMergeDocs option
116 * maxMergeDocs is a largest number of documents ever merged by addDocument().
117 * Small values (e.g., less than 10,000) are best for interactive indexing,
118 * as this limits the length of pauses while indexing to a few seconds.
119 * Larger values are best for batched indexing and speedier searches.
121 * Default value is PHP_INT_MAX
125 public function getMaxMergeDocs();
128 * Set index maxMergeDocs option
130 * maxMergeDocs is a largest number of documents ever merged by addDocument().
131 * Small values (e.g., less than 10,000) are best for interactive indexing,
132 * as this limits the length of pauses while indexing to a few seconds.
133 * Larger values are best for batched indexing and speedier searches.
135 * Default value is PHP_INT_MAX
137 * @param integer $maxMergeDocs
139 public function setMaxMergeDocs($maxMergeDocs);
142 * Retrieve index mergeFactor option
144 * mergeFactor determines how often segment indices are merged by addDocument().
145 * With smaller values, less RAM is used while indexing,
146 * and searches on unoptimized indices are faster,
147 * but indexing speed is slower.
148 * With larger values, more RAM is used during indexing,
149 * and while searches on unoptimized indices are slower,
150 * indexing is faster.
151 * Thus larger values (> 10) are best for batch index creation,
152 * and smaller values (< 10) for indices that are interactively maintained.
154 * Default value is 10
158 public function getMergeFactor();
161 * Set index mergeFactor option
163 * mergeFactor determines how often segment indices are merged by addDocument().
164 * With smaller values, less RAM is used while indexing,
165 * and searches on unoptimized indices are faster,
166 * but indexing speed is slower.
167 * With larger values, more RAM is used during indexing,
168 * and while searches on unoptimized indices are slower,
169 * indexing is faster.
170 * Thus larger values (> 10) are best for batch index creation,
171 * and smaller values (< 10) for indices that are interactively maintained.
173 * Default value is 10
175 * @param integer $maxMergeDocs
177 public function setMergeFactor($mergeFactor);
180 * Performs a query against the index and returns an array
181 * of Zend_Search_Lucene_Search_QueryHit objects.
182 * Input is a string or Zend_Search_Lucene_Search_Query.
184 * @param mixed $query
185 * @return array Zend_Search_Lucene_Search_QueryHit
186 * @throws Zend_Search_Lucene_Exception
188 public function find($query);
191 * Returns a list of all unique field names that exist in this index.
193 * @param boolean $indexed
196 public function getFieldNames($indexed = false);
199 * Returns a Zend_Search_Lucene_Document object for the document
200 * number $id in this index.
202 * @param integer|Zend_Search_Lucene_Search_QueryHit $id
203 * @return Zend_Search_Lucene_Document
205 public function getDocument($id);
208 * Returns true if index contain documents with specified term.
210 * Is used for query optimization.
212 * @param Zend_Search_Lucene_Index_Term $term
215 public function hasTerm(Zend_Search_Lucene_Index_Term
$term);
218 * Returns IDs of all the documents containing term.
220 * @param Zend_Search_Lucene_Index_Term $term
223 public function termDocs(Zend_Search_Lucene_Index_Term
$term);
226 * Returns an array of all term freqs.
227 * Return array structure: array( docId => freq, ...)
229 * @param Zend_Search_Lucene_Index_Term $term
232 public function termFreqs(Zend_Search_Lucene_Index_Term
$term);
235 * Returns an array of all term positions in the documents.
236 * Return array structure: array( docId => array( pos1, pos2, ...), ...)
238 * @param Zend_Search_Lucene_Index_Term $term
241 public function termPositions(Zend_Search_Lucene_Index_Term
$term);
244 * Returns the number of documents in this index containing the $term.
246 * @param Zend_Search_Lucene_Index_Term $term
249 public function docFreq(Zend_Search_Lucene_Index_Term
$term);
252 * Retrive similarity used by index reader
254 * @return Zend_Search_Lucene_Search_Similarity
256 public function getSimilarity();
259 * Returns a normalization factor for "field, document" pair.
262 * @param string $fieldName
265 public function norm($id, $fieldName);
268 * Returns true if any documents have been deleted from this index.
272 public function hasDeletions();
275 * Deletes a document from the index.
276 * $id is an internal document id
278 * @param integer|Zend_Search_Lucene_Search_QueryHit $id
279 * @throws Zend_Search_Lucene_Exception
281 public function delete($id);
284 * Adds a document to this index.
286 * @param Zend_Search_Lucene_Document $document
288 public function addDocument(Zend_Search_Lucene_Document
$document);
291 * Commit changes resulting from delete() or undeleteAll() operations.
293 public function commit();
298 * Merges all segments into one
300 public function optimize();
303 * Returns an array of all terms in this index.
307 public function terms();
310 * Undeletes all documents currently marked as deleted in this index.
312 public function undeleteAll();
316 * Add reference to the index object
320 public function addReference();
323 * Remove reference from the index object
325 * When reference count becomes zero, index is closed and resources are cleaned up
329 public function removeReference();