说明他更新数据库和索引文件,不同步,导致数据有差异,
这种情况你只能看看他的程序了。。

解决方案 »

  1.   

    数据库更新进去了,为什么索引文件里面没有更新呢。。
      

  2.   


        public void addDocument(String Title, String Url, String PictureAddr, String getCreatetime, String Length, String pname, String keyWord, 
                IndexWriter indexWriter)
        {
            Document document = new Document();
            System.out.println(Title);
            document.add(new Field("title", Title, org.apache.lucene.document.Field.Store.YES, org.apache.lucene.document.Field.Index.TOKENIZED));
            document.add(new Field("url", Url, org.apache.lucene.document.Field.Store.YES, org.apache.lucene.document.Field.Index.NO));
            document.add(new Field("pictureAddr", PictureAddr, org.apache.lucene.document.Field.Store.YES, org.apache.lucene.document.Field.Index.NO));
            document.add(new Field("createtime", getCreatetime, org.apache.lucene.document.Field.Store.YES, org.apache.lucene.document.Field.Index.NO));
            document.add(new Field("length", Length, org.apache.lucene.document.Field.Store.YES, org.apache.lucene.document.Field.Index.NO));
            document.add(new Field("pname", pname, org.apache.lucene.document.Field.Store.YES, org.apache.lucene.document.Field.Index.TOKENIZED));
            if(keyWord.length() > 0)
                document.add(new Field("keyWord", keyWord, org.apache.lucene.document.Field.Store.YES, org.apache.lucene.document.Field.Index.TOKENIZED));
            try
            {
                indexWriter.addDocument(document);
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
        }其他地方调用addDocument(),并且执行了
     indexWriter.optimize();
     indexWriter.close();弄不明白,为什么索引没有更新进去