import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -16,11 +16,12 @@
|
||||
* @package Zend_Search_Lucene
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Lucene.php 17164 2009-07-27 03:59:23Z matthew $
|
||||
* @version $Id: Lucene.php 19012 2009-11-17 15:13:49Z alexander $
|
||||
*/
|
||||
|
||||
/** Zend_Search_Lucene_Document */
|
||||
require_once 'Zend/Search/Lucene/Document.php';
|
||||
|
||||
/** User land classes and interfaces turned on by Zend/Search/Lucene.php file inclusion. */
|
||||
/** @todo Section should be removed with ZF 2.0 release as obsolete */
|
||||
|
||||
/** Zend_Search_Lucene_Document_Html */
|
||||
require_once 'Zend/Search/Lucene/Document/Html.php';
|
||||
@ -34,53 +35,56 @@ require_once 'Zend/Search/Lucene/Document/Pptx.php';
|
||||
/** Zend_Search_Lucene_Document_Xlsx */
|
||||
require_once 'Zend/Search/Lucene/Document/Xlsx.php';
|
||||
|
||||
/** Zend_Search_Lucene_Storage_Directory_Filesystem */
|
||||
require_once 'Zend/Search/Lucene/Storage/Directory/Filesystem.php';
|
||||
|
||||
/** Zend_Search_Lucene_Storage_File_Memory */
|
||||
require_once 'Zend/Search/Lucene/Storage/File/Memory.php';
|
||||
|
||||
/** Zend_Search_Lucene_Index_Term */
|
||||
require_once 'Zend/Search/Lucene/Index/Term.php';
|
||||
|
||||
/** Zend_Search_Lucene_Index_TermInfo */
|
||||
require_once 'Zend/Search/Lucene/Index/TermInfo.php';
|
||||
|
||||
/** Zend_Search_Lucene_Index_SegmentInfo */
|
||||
require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
|
||||
|
||||
/** Zend_Search_Lucene_Index_FieldInfo */
|
||||
require_once 'Zend/Search/Lucene/Index/FieldInfo.php';
|
||||
|
||||
/** Zend_Search_Lucene_Index_Writer */
|
||||
require_once 'Zend/Search/Lucene/Index/Writer.php';
|
||||
|
||||
/** Zend_Search_Lucene_Search_QueryParser */
|
||||
require_once 'Zend/Search/Lucene/Search/QueryParser.php';
|
||||
|
||||
/** Zend_Search_Lucene_Search_QueryHit */
|
||||
require_once 'Zend/Search/Lucene/Search/QueryHit.php';
|
||||
|
||||
/** Zend_Search_Lucene_Search_Similarity */
|
||||
require_once 'Zend/Search/Lucene/Search/Similarity.php';
|
||||
/** Zend_Search_Lucene_Analysis_Analyzer */
|
||||
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
|
||||
|
||||
/** Zend_Search_Lucene_Index_TermsPriorityQueue */
|
||||
require_once 'Zend/Search/Lucene/Index/TermsPriorityQueue.php';
|
||||
/** Zend_Search_Lucene_Search_Query_Term */
|
||||
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
|
||||
|
||||
/** Zend_Search_Lucene_TermStreamsPriorityQueue */
|
||||
require_once 'Zend/Search/Lucene/TermStreamsPriorityQueue.php';
|
||||
/** Zend_Search_Lucene_Search_Query_Phrase */
|
||||
require_once 'Zend/Search/Lucene/Search/Query/Phrase.php';
|
||||
|
||||
/** Zend_Search_Lucene_Index_DocsFilter */
|
||||
require_once 'Zend/Search/Lucene/Index/DocsFilter.php';
|
||||
/** Zend_Search_Lucene_Search_Query_MultiTerm */
|
||||
require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
|
||||
|
||||
/** Zend_Search_Lucene_LockManager */
|
||||
require_once 'Zend/Search/Lucene/LockManager.php';
|
||||
/** Zend_Search_Lucene_Search_Query_Wildcard */
|
||||
require_once 'Zend/Search/Lucene/Search/Query/Wildcard.php';
|
||||
|
||||
/** Zend_Search_Lucene_Search_Query_Range */
|
||||
require_once 'Zend/Search/Lucene/Search/Query/Range.php';
|
||||
|
||||
/** Zend_Search_Lucene_Search_Query_Fuzzy */
|
||||
require_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php';
|
||||
|
||||
/** Zend_Search_Lucene_Search_Query_Boolean */
|
||||
require_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
|
||||
|
||||
/** Zend_Search_Lucene_Search_Query_Empty */
|
||||
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
|
||||
|
||||
/** Zend_Search_Lucene_Search_Query_Insignificant */
|
||||
require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
|
||||
|
||||
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
|
||||
/** Zend_Search_Lucene_Interface */
|
||||
require_once 'Zend/Search/Lucene/Interface.php';
|
||||
|
||||
/** Zend_Search_Lucene_Proxy */
|
||||
require_once 'Zend/Search/Lucene/Proxy.php';
|
||||
/** Zend_Search_Lucene_Index_SegmentInfo */
|
||||
require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
|
||||
|
||||
/** Zend_Search_Lucene_LockManager */
|
||||
require_once 'Zend/Search/Lucene/LockManager.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
@ -139,7 +143,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
private $_writer = null;
|
||||
|
||||
/**
|
||||
* Array of Zend_Search_Lucene_Index_SegmentInfo objects for this index.
|
||||
* Array of Zend_Search_Lucene_Index_SegmentInfo objects for current version of index.
|
||||
*
|
||||
* @var array Zend_Search_Lucene_Index_SegmentInfo
|
||||
*/
|
||||
@ -201,6 +205,9 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
*/
|
||||
public static function create($directory)
|
||||
{
|
||||
/** Zend_Search_Lucene_Proxy */
|
||||
require_once 'Zend/Search/Lucene/Proxy.php';
|
||||
|
||||
return new Zend_Search_Lucene_Proxy(new Zend_Search_Lucene($directory, true));
|
||||
}
|
||||
|
||||
@ -212,6 +219,9 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
*/
|
||||
public static function open($directory)
|
||||
{
|
||||
/** Zend_Search_Lucene_Proxy */
|
||||
require_once 'Zend/Search/Lucene/Proxy.php';
|
||||
|
||||
return new Zend_Search_Lucene_Proxy(new Zend_Search_Lucene($directory, false));
|
||||
}
|
||||
|
||||
@ -477,7 +487,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
* IndexReader constructor needs Directory as a parameter. It should be
|
||||
* a string with a path to the index folder or a Directory object.
|
||||
*
|
||||
* @param mixed $directory
|
||||
* @param Zend_Search_Lucene_Storage_Directory_Filesystem|string $directory
|
||||
* @throws Zend_Search_Lucene_Exception
|
||||
*/
|
||||
public function __construct($directory = null, $create = false)
|
||||
@ -487,12 +497,13 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
throw new Zend_Search_Exception('No index directory specified');
|
||||
}
|
||||
|
||||
if ($directory instanceof Zend_Search_Lucene_Storage_Directory_Filesystem) {
|
||||
$this->_directory = $directory;
|
||||
$this->_closeDirOnExit = false;
|
||||
} else {
|
||||
if (is_string($directory)) {
|
||||
require_once 'Zend/Search/Lucene/Storage/Directory/Filesystem.php';
|
||||
$this->_directory = new Zend_Search_Lucene_Storage_Directory_Filesystem($directory);
|
||||
$this->_closeDirOnExit = true;
|
||||
} else {
|
||||
$this->_directory = $directory;
|
||||
$this->_closeDirOnExit = false;
|
||||
}
|
||||
|
||||
$this->_segmentInfos = array();
|
||||
@ -529,6 +540,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
$this->_generation++;
|
||||
}
|
||||
|
||||
require_once 'Zend/Search/Lucene/Index/Writer.php';
|
||||
Zend_Search_Lucene_Index_Writer::createIndex($this->_directory, $this->_generation, $nameCounter);
|
||||
|
||||
Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
|
||||
@ -611,8 +623,11 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
*/
|
||||
private function _getIndexWriter()
|
||||
{
|
||||
if (!$this->_writer instanceof Zend_Search_Lucene_Index_Writer) {
|
||||
$this->_writer = new Zend_Search_Lucene_Index_Writer($this->_directory, $this->_segmentInfos, $this->_formatVersion);
|
||||
if ($this->_writer === null) {
|
||||
require_once 'Zend/Search/Lucene/Index/Writer.php';
|
||||
$this->_writer = new Zend_Search_Lucene_Index_Writer($this->_directory,
|
||||
$this->_segmentInfos,
|
||||
$this->_formatVersion);
|
||||
}
|
||||
|
||||
return $this->_writer;
|
||||
@ -881,13 +896,15 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
* of Zend_Search_Lucene_Search_QueryHit objects.
|
||||
* Input is a string or Zend_Search_Lucene_Search_Query.
|
||||
*
|
||||
* @param mixed $query
|
||||
* @param Zend_Search_Lucene_Search_QueryParser|string $query
|
||||
* @return array Zend_Search_Lucene_Search_QueryHit
|
||||
* @throws Zend_Search_Lucene_Exception
|
||||
*/
|
||||
public function find($query)
|
||||
{
|
||||
if (is_string($query)) {
|
||||
require_once 'Zend/Search/Lucene/Search/QueryParser.php';
|
||||
|
||||
$query = Zend_Search_Lucene_Search_QueryParser::parse($query);
|
||||
}
|
||||
|
||||
@ -908,6 +925,9 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
|
||||
$topScore = 0;
|
||||
|
||||
/** Zend_Search_Lucene_Search_QueryHit */
|
||||
require_once 'Zend/Search/Lucene/Search/QueryHit.php';
|
||||
|
||||
foreach ($query->matchedDocs() as $id => $num) {
|
||||
$docScore = $query->score($id, $this);
|
||||
if( $docScore != 0 ) {
|
||||
@ -953,8 +973,8 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
$sortArgs = array();
|
||||
|
||||
// PHP 5.3 now expects all arguments to array_multisort be passed by
|
||||
// reference; since constants can't be passed by reference, create
|
||||
// some placeholder variables.
|
||||
// reference (if it's invoked through call_user_func_array());
|
||||
// since constants can't be passed by reference, create some placeholder variables.
|
||||
$sortReg = SORT_REGULAR;
|
||||
$sortAsc = SORT_ASC;
|
||||
$sortNum = SORT_NUMERIC;
|
||||
@ -967,26 +987,31 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
throw new Zend_Search_Lucene_Exception('Field name must be a string.');
|
||||
}
|
||||
|
||||
if (!in_array($fieldName, $fieldNames)) {
|
||||
throw new Zend_Search_Lucene_Exception('Wrong field name.');
|
||||
}
|
||||
|
||||
$valuesArray = array();
|
||||
foreach ($hits as $hit) {
|
||||
try {
|
||||
$value = $hit->getDocument()->getFieldValue($fieldName);
|
||||
} catch (Zend_Search_Lucene_Exception $e) {
|
||||
if (strpos($e->getMessage(), 'not found') === false) {
|
||||
throw $e;
|
||||
} else {
|
||||
$value = null;
|
||||
}
|
||||
if (strtolower($fieldName) == 'score') {
|
||||
$sortArgs[] = $scores;
|
||||
} else {
|
||||
if (!in_array($fieldName, $fieldNames)) {
|
||||
throw new Zend_Search_Lucene_Exception('Wrong field name.');
|
||||
}
|
||||
|
||||
$valuesArray[] = $value;
|
||||
}
|
||||
$valuesArray = array();
|
||||
foreach ($hits as $hit) {
|
||||
try {
|
||||
$value = $hit->getDocument()->getFieldValue($fieldName);
|
||||
} catch (Zend_Search_Lucene_Exception $e) {
|
||||
if (strpos($e->getMessage(), 'not found') === false) {
|
||||
throw $e;
|
||||
} else {
|
||||
$value = null;
|
||||
}
|
||||
}
|
||||
|
||||
$sortArgs[] = &$valuesArray;
|
||||
$valuesArray[] = $value;
|
||||
}
|
||||
|
||||
$sortArgs[] = &$valuesArray;
|
||||
unset($valuesArray);
|
||||
}
|
||||
|
||||
if ($count + 1 < count($argList) && is_integer($argList[$count+1])) {
|
||||
$count++;
|
||||
@ -1119,7 +1144,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
public function hasTerm(Zend_Search_Lucene_Index_Term $term)
|
||||
{
|
||||
foreach ($this->_segmentInfos as $segInfo) {
|
||||
if ($segInfo->getTermInfo($term) instanceof Zend_Search_Lucene_Index_TermInfo) {
|
||||
if ($segInfo->getTermInfo($term) !== null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1147,7 +1172,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
|
||||
if (count($subResults) == 0) {
|
||||
return array();
|
||||
} else if (count($subResults) == 0) {
|
||||
} else if (count($subResults) == 1) {
|
||||
// Index is optimized (only one segment)
|
||||
// Do not perform array reindexing
|
||||
return reset($subResults);
|
||||
@ -1181,7 +1206,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
|
||||
if (count($subResults) == 0) {
|
||||
return array();
|
||||
} else if (count($subResults) == 0) {
|
||||
} else if (count($subResults) == 1) {
|
||||
// Index is optimized (only one segment)
|
||||
// Do not perform array reindexing
|
||||
return reset($subResults);
|
||||
@ -1263,6 +1288,9 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
*/
|
||||
public function getSimilarity()
|
||||
{
|
||||
/** Zend_Search_Lucene_Search_Similarity */
|
||||
require_once 'Zend/Search/Lucene/Search/Similarity.php';
|
||||
|
||||
return Zend_Search_Lucene_Search_Similarity::getDefault();
|
||||
}
|
||||
|
||||
@ -1415,6 +1443,9 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
{
|
||||
$result = array();
|
||||
|
||||
/** Zend_Search_Lucene_Index_TermsPriorityQueue */
|
||||
require_once 'Zend/Search/Lucene/Index/TermsPriorityQueue.php';
|
||||
|
||||
$segmentInfoQueue = new Zend_Search_Lucene_Index_TermsPriorityQueue();
|
||||
|
||||
foreach ($this->_segmentInfos as $segmentInfo) {
|
||||
@ -1456,11 +1487,14 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
|
||||
*/
|
||||
public function resetTermsStream()
|
||||
{
|
||||
if ($this->_termsStream === null) {
|
||||
if ($this->_termsStream === null) {
|
||||
/** Zend_Search_Lucene_TermStreamsPriorityQueue */
|
||||
require_once 'Zend/Search/Lucene/TermStreamsPriorityQueue.php';
|
||||
|
||||
$this->_termsStream = new Zend_Search_Lucene_TermStreamsPriorityQueue($this->_segmentInfos);
|
||||
} else {
|
||||
$this->_termsStream->resetTermsStream();
|
||||
}
|
||||
} else {
|
||||
$this->_termsStream->resetTermsStream();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user