Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Zend framework 如何提高Zend_Search_Lucene查询的性能?_Zend Framework_Search_Lucene_Zend Search Lucene - Fatal编程技术网

Zend framework 如何提高Zend_Search_Lucene查询的性能?

Zend framework 如何提高Zend_Search_Lucene查询的性能?,zend-framework,search,lucene,zend-search-lucene,Zend Framework,Search,Lucene,Zend Search Lucene,如何改进查询,如下所示 我的索引已完全优化,除item_id是一个关键字字段外,所有字段均未存储 问题在于“if($auth){”节。如果删除此节,搜索时间始终在1秒以下,但添加此节时,搜索时间为5秒或更长。显然,这是一个更复杂的查询,但没有它我无法生存。我需要该节中的逻辑,以仅获取用户有权查看的搜索结果。我知道,搜索速度放缓是我所做的t如果我删除“if($authQuery){$query->addSubquery($authQuery,true);}”这一行,搜索速度会非常快 我试图在“if

如何改进查询,如下所示

我的索引已完全优化,除item_id是一个关键字字段外,所有字段均未存储

问题在于“if($auth){”节。如果删除此节,搜索时间始终在1秒以下,但添加此节时,搜索时间为5秒或更长。显然,这是一个更复杂的查询,但没有它我无法生存。我需要该节中的逻辑,以仅获取用户有权查看的搜索结果。我知道,搜索速度放缓是我所做的t如果我删除“if($authQuery){$query->addSubquery($authQuery,true);}”这一行,搜索速度会非常快

我试图在“if($auth){”部分基本上实现以下逻辑:

lucene字段gi_aro、gc_aro、i_access和c_access都只包含一个整数

if ((array_in({gi_aro}, $gmid) OR {i_access} <= $gid)
    AND (array_in({gc_aro}, $gmid) {OR c_access} <= $gid)) {
  include in search results
}

只检查不在索引中的结果如何?将某种键保存到索引中(db主键、guid,实际上是任何键)。然后获取结果并删除用户不允许看到的结果

$allowedArray = $acl->getAllowedIds();
// check happens when echoing the content to prevent double cycling (filtering and echoing in view)
foreach ($result as $item) {
    if (in_array($item->keyVaue, $allowedArray)) {
        //echo
    }
} 

编辑:请注意,这取决于大多数查询的结果。如果有人说,感谢大家的响应,但查询通常会返回1000多个结果,循环这些结果只会花费太多时间。我以前也这么做过,但后来我意识到循环成本太高,所以我开始减少结果集d只“触摸”我将要显示的结果,但搜索速度太慢。我不记得是如何让它运行的,但暂时可以接受。如果速度太慢,我想我将不得不切换到Solr。其他选项将是回退到SQL:)
$allowedArray = $acl->getAllowedIds();
// check happens when echoing the content to prevent double cycling (filtering and echoing in view)
foreach ($result as $item) {
    if (in_array($item->keyVaue, $allowedArray)) {
        //echo
    }
}