【问题标题】:PHP: Checking if a directory contains a Zend_Search_Lucene indexPHP:检查目录是否包含 Zend_Search_Lucene 索引
【发布时间】:2010-10-11 11:50:48
【问题描述】:

我正在寻找一种可靠的方法来检查目录是否包含 Zend_Search_Lucene 索引。目前,我设法解决这个问题的唯一方法是使用以下代码检查返回给我的异常内容:

<?php
try
{
    $newIndex = Zend_Search_Lucene::open( $luceneDir );
} catch ( Zend_Search_Lucene_Exception $e ) {
    if ( strpos( $e->getMessage( ), 'in the specified directory' ) !== false )
    {
        $newIndex = Zend_Search_Lucene::create( $luceneDir );
    }
}
?>

这种方法并不理想,而且对 API 的检查似乎也不是很有用。有谁知道是否有一种简单的方法可以查看 $luceneDir 是否包含 Zend_Search_Lucene 索引?

【问题讨论】:

    标签: php zend-framework exception zend-search-lucene


    【解决方案1】:

    你可以先试试看是否有索引段号文件

    file_exists($luceneDir.'segments.gen')
    

    【讨论】:

      猜你喜欢
      • 2011-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-10
      • 2017-04-28
      • 1970-01-01
      • 2011-07-15
      相关资源
      最近更新 更多