本文整理汇总了PHP中Zend_Search_Lucene_Interface::termPositions方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_Interface::termPositions方法的具体用法?PHP Zend_Search_Lucene_Interface::termPositions怎么用?PHP Zend_Search_Lucene_Interface::termPositions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Search_Lucene_Interface
的用法示例。
在下文中一共展示了Zend_Search_Lucene_Interface::termPositions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: termPositions
/**
* Returns an array of all term positions in the documents.
* Return array structure: array( docId => array( pos1, pos2, ...), ...)
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return array
*/
public function termPositions(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
{
return $this->_index->termPositions($term, $docsFilter);
}
示例2: execute
/**
* Execute query in context of index reader
* It also initializes necessary internal structures
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
*/
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
{
$this->_resVector = null;
if (count($this->_terms) == 0) {
$this->_resVector = array();
}
$resVectors = array();
$resVectorsSizes = array();
$resVectorsIds = array();
// is used to prevent arrays comparison
foreach ($this->_terms as $termId => $term) {
$resVectors[] = array_flip($reader->termDocs($term));
$resVectorsSizes[] = count(end($resVectors));
$resVectorsIds[] = $termId;
$this->_termsPositions[$termId] = $reader->termPositions($term);
}
// sort resvectors in order of subquery cardinality increasing
array_multisort($resVectorsSizes, SORT_ASC, SORT_NUMERIC, $resVectorsIds, SORT_ASC, SORT_NUMERIC, $resVectors);
foreach ($resVectors as $nextResVector) {
if ($this->_resVector === null) {
$this->_resVector = $nextResVector;
} else {
//$this->_resVector = array_intersect_key($this->_resVector, $nextResVector);
/**
* This code is used as workaround for array_intersect_key() slowness problem.
*/
$updatedVector = array();
foreach ($this->_resVector as $id => $value) {
if (isset($nextResVector[$id])) {
$updatedVector[$id] = $value;
}
}
$this->_resVector = $updatedVector;
}
if (count($this->_resVector) == 0) {
// Empty result set, we don't need to check other terms
break;
}
}
// ksort($this->_resVector, SORT_NUMERIC);
// Docs are returned ordered. Used algorithm doesn't change elements order.
// Initialize weight if it's not done yet
$this->_initWeight($reader);
}
示例3: execute
/**
* Execute query in context of index reader
* It also initializes necessary internal structures
*
* @param Zend_Search_Lucene_Interface $reader
*/
public function execute(Zend_Search_Lucene_Interface $reader)
{
$this->_resVector = null;
if (count($this->_terms) == 0) {
$this->_resVector = array();
}
foreach ($this->_terms as $termId => $term) {
if ($this->_resVector === null) {
$this->_resVector = array_flip($reader->termDocs($term));
} else {
$this->_resVector = array_intersect_key($this->_resVector, array_flip($reader->termDocs($term)));
}
if (count($this->_resVector) == 0) {
// Empty result set, we don't need to check other terms
break;
}
$this->_termsPositions[$termId] = $reader->termPositions($term);
}
ksort($this->_resVector, SORT_NUMERIC);
// Initialize weight if it's not done yet
$this->_initWeight($reader);
}
示例4: termPositions
/**
* Returns an array of all term positions in the documents.
* Return array structure: array( docId => array( pos1, pos2, ...), ...)
*
* @param Zend_Search_Lucene_Index_Term $term
* @return array
*/
public function termPositions(Zend_Search_Lucene_Index_Term $term)
{
return $this->_index->termPositions($term);
}
示例5: execute
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
{
$this->_resVector = null;
if (count($this->_terms) == 0) {
$this->_resVector = array();
}
$resVectors = array();
$resVectorsSizes = array();
$resVectorsIds = array();
foreach ($this->_terms as $termId => $term) {
$resVectors[] = array_flip($reader->termDocs($term));
$resVectorsSizes[] = count(end($resVectors));
$resVectorsIds[] = $termId;
$this->_termsPositions[$termId] = $reader->termPositions($term);
}
array_multisort($resVectorsSizes, SORT_ASC, SORT_NUMERIC, $resVectorsIds, SORT_ASC, SORT_NUMERIC, $resVectors);
foreach ($resVectors as $nextResVector) {
if ($this->_resVector === null) {
$this->_resVector = $nextResVector;
} else {
$updatedVector = array();
foreach ($this->_resVector as $id => $value) {
if (isset($nextResVector[$id])) {
$updatedVector[$id] = $value;
}
}
$this->_resVector = $updatedVector;
}
if (count($this->_resVector) == 0) {
break;
}
}
$this->_initWeight($reader);
}