我们信息检索大作业是做一个小型搜索引擎,我在试着用ajax和lucene,在看电子书《征服ajax-lucene构建搜索引擎》,按照书上内容敲了程序,其中有两行代码如下:
doc.add(Field.Text("contents", reader));
doc.add(Field.Keyword("path",f.getAbsolutePath()));报错,说是the method Text is not defined for the type Field;
                  the method Keyword is not defined for the type Field;由于还是菜鸟,请高手们赐教啊

解决方案 »

  1.   

    Field是哪个类? 查查有Test和Keyword这两个静态方法吗? ps: 看方法的命名不像是java的...
      

  2.   

    Field.Text(... => Field.text
    小写t.
      

  3.   

    谢谢大家,这个问题已经解决了,那个类好像不是java的,我看了一个外国人的建议,改成这样就可以了:
    doc.add(new Field('contents', reader));
    doc.add(new Field('path', f.getAbsolutePath(), Field.Store.YES, Field.Index.UN_TOKENIZED));谢谢大家,分数大家平分一下吧
      

  4.   

    一个外国人写的建议:
    These methods have been considered deprecated since version 1.9.1. The javadocs for version 2.0 don't even mention them, not even in the list of deprecated methods. I had to download the javadocs for 1.9.1 to find out.
    Please, guys, post an errata somewhere. And if some Lucene developer is around, please don't remove from the list of deprecated methods the ones that have been phased-out in old versions; it is useful for adapting old code to use newer versions of the library. 这个也是我从网上别人博客里找到的,呵呵,问题解决了就好啦
      

  5.   

    the method getHibernateTemplate()is not defined for the type UserDaoImpl请问这个问题怎么解决呢
      

  6.   

    package com.dao.impl;import java.util.List;import com.dao.IUserDao;public class UserDaoImpl implements IUserDao { public List getUserBynameandpass(String name, String pass) {
    String hql="from Users as u where u.username='"+name+"'and u.password='"+pass+"'";
    return this.getHibernateTemplate().find(hql);
    }
    }
    显示the method getHibernateTemplate()is not defined for the type UserDaoImpl请问这个问题怎么解决呢,谢谢啊
      

  7.   

    忘了引入import org.springframework.orm.hibernate3.support.HibernateDaoSupport;