【问题标题】:PHP Lucene - Indexation - Fails in Linux after 2.000.000 system blocksPHP Lucene - 索引 - 在 2.000.000 个系统块后在 Linux 中失败
【发布时间】:2011-09-11 20:10:15
【问题描述】:

我一直致力于使用 Zend Framework 最新版本创建索引。界面工作正常,其他一切正常。 我现在遇到的问题是“重新索引”或创建索引。我已经检查了其他所有内容,清理了数据并仔细检查了数据的质量。

进程总是在最有可能的记录 15.000 和 2.000.000 的索引目录上停止。我决定用 lucene3.0.3 版本构建一个用 java 编译的应用程序来运行索引。

Fatal error: Uncaught exception 'Zend_Search_Lucene_Exception' with message 'Unsupported segments file format' in 


Zend Lucene 使用的最新格式似乎是 2.3
任何想法如何解决这个问题,我真的很感谢你的意见

【问题讨论】:

  • 不确定系统块(或“索引目录”)是什么意思。但我猜你的意思是一些操作系统限制,所以运行命令ulimit -a。如果任何结果未显示“无限”,则将输出作为对您问题的编辑发布。祝你好运。

标签: php linux lucene


【解决方案1】:

我没有这方面的经验。但是在 zend lucene 网站上,他们声明当前支持的 lucene 索引版本是 2.3。可能是版本 3.0.3 不完全支持。

[1] 当前支持的 Lucene 索引文件格式版本为 2.3(从 Zend Framework 1.6 开始)。

见:http://framework.zend.com/manual/en/zend.search.lucene.java-lucene.html

【讨论】:

  • //这是我的主要 public static void main(String[] args) throws Exception { String indexDir = args[0]; //1 System.out.println("indexDir " + indexDir );长开始 = System.currentTimeMillis();索引器 indexer = new Indexer(indexDir); int numIndexed = 0;字符串 par = "%";尝试 { numIndexed = indexer.index_main( par ); } 最后 { indexer.close(); } 长端 = System.currentTimeMillis(); System.out.println("索引 " + numIndexed + " 文件占用 " + (end - start) + " 毫秒"); } 私人 IndexWriter 作家;
  • public Indexer(String indexDir) throws IOException { Directory dir = FSDirectory.open(new File(indexDir)); writer = new IndexWriter(dir, new StandardAnalyzer(Version.LUCENE_23), true, IndexWriter.MaxFieldLength.LIMITED); } //为使我的 FileWrite 实例与 2.3 兼容,需要进行哪些设置?
  • 在 PHP 中重新索引是否有遇到问题...?我不认为我会直接使用 PHP 中的重新索引。那么任何人都可以帮助我使用 Java 吗?
  • @CarlosRamirez :请将 cmets 中的代码移动到问题正文中并使用提供的格式。如果我们要帮助你,你必须帮助我们。祝你好运!
【解决方案2】:

我自定义了这个站点http://www.techcrony.info/?p=33的例子,这个例子从数据目录中读取文本文件。所以,新的自定义函数需要从 MySQL 数据库中读取信息:

public static void main(String[] args) throws Exception
{....System.out.print("Index dir arg_0 : " + indexDir + "\r");
    String id ="%";

    long start = new Date().getTime();
    int numIndexed = index_main(indexDir, id);
    long end = new Date().getTime();

    System.out.print("End Program... \r");

}  
private static int index_main(File indexDir, String id )throws IOException {

    int numIndexed = 0;
    try{
        IndexWriter writer =
            new IndexWriter(indexDir, new StandardAnalyzer(), true);
        writer.setUseCompoundFile(false);

      java.sql.Connection conn = linktodata();
      int rowCount = 0;
     ...

如你所见,我使用了 lucene-core-2.3.0.jar

javac -cp .:lucene-core-2.3.0.jar:mysql-connector-java-5.1.16-bin.jar Indexer.java

Run:

java -cp .:lucene-core-2.3.0.jar:mysql-connector-java-5.1.16-bin.jar Indexer /home/public_html/index_main

现在最重要的问题是,是否有人知道 PHP lucene 是否能够管理超过 1.000.000 个文档?

【讨论】:

  • "是否有人知道 PHP lucene 是否能够管理超过 1.000.000 个文档?"。大约 3 年前,我使用 Zend_Lucene,索引为几百兆,可能是一次演出。我们切换到 solr 并且从未回头。有许多查询,Zend_Lucene 花费的时间实际上比 solr 长 1000 倍(在 solr 上花费 ms 的查询,在 Zend_Lucene 中花费几秒钟)。 IMO,不要将 Zend_Lucene 用于超过几千个小文档的任何内容。这是一种在纯 PHP 应用程序中对非常小的文档集进行搜索的便捷方式,仅此而已。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-12-23
  • 2015-09-27
  • 2013-05-02
  • 1970-01-01
  • 1970-01-01
  • 2010-09-20
  • 1970-01-01
相关资源
最近更新 更多