zwj1533 2009-12-07 11:21
浏览 218
已采纳

关于lucene 的问题。

我的问题是:为什么lucene中的Field("id",id,Field.Store.NO,Field.Index.TOKENIZED)执行没有反映。

具体情况是这样的。我Tomcat 4 + jdk1.4+myEclipse6.5 +SSH框架。Lucene测试写在实现类中。在Action写一个方法调用。但是单步执行到 Field构造对象的时候就没有反映。如果我写一个测试的 public static void main(String args[]){
Field("id",id,Field.Store.NO,Field.Index.TOKENIZED);}没有问题。能够正常的执行下去。让我百思不得其解????我是一个菜鸟 请大虾们指点。不生感激!!!!!!!!!!
[b]问题补充:[/b]
public static final String path = "D:\piccjy\index\vehicle\";

public void initVehicleIndex() throws Exception {
IndexWriter writer = new IndexWriter(FSDirectory.getDirectory(path, true), new StandardAnalyzer(), true);

List list = getListVehicle();
ZcClzlb entity =null;
for(int i=0;i<list.size();i++){
entity = new ZcClzlb();
entity = (ZcClzlb)list.get(i);
Document doc = LucenceServiceImpl.document(entity.getId(), entity.getClbzmc());
writer.addDocument(doc);

}
writer.close();
}
private static Document document(String id, String text) {
Document doc = new Document();
try {
org.apache.lucene.document.Field.Store store = org.apache.lucene.document.Field.Store.YES;
org.apache.lucene.document.Field.Index index = org.apache.lucene.document.Field.Index.NO_NORMS;
org.apache.lucene.document.Field.TermVector termV = org.apache.lucene.document.Field.TermVector.NO;//.TermVector.NO
org.apache.lucene.document.Field field = new org.apache.lucene.document.Field("id",id,store,index,termV);
doc.add(field);
} catch (Exception e) {
System.out.println(e.getMessage());
}
return doc;
}
[b]问题补充:[/b]
我第一次接触 这个东东!不太理解2位大虾的意思!能说具体点么?如果可以,可以交个朋友!QQ 727645052 谢谢!

  • 写回答

3条回答 默认 最新

  • 宁静-夏天 2009-12-07 13:17
    关注

    [quote]
    public static final String path = "D:\piccjy\index\vehicle\";

    [/quote]
    你使用的同一个路径?
    检查下是否有多线程使用多个indexWriter,
    并共同使用同一个索引目录。

    楼上说的情况是可能存在的,
    一个indexWriter正在使用这个path目录
    另外一个indexWriter构造则要清空index,但该目录下有其他的indexWriter的 writer.lock

    使用同步吧,或者考虑下策略性的分离index路径

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题