val_HH 2017-08-06 12:37 采纳率: 0%
浏览 1254

lucene中FSDirectory对象中为什么没有open类

package com.lucene;

import java.io.File;
import java.io.IOException;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.LongField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;
import org.apache.lucene.document.Field.Store;

public class Lucene {

public void CreateIndex(){
    Document doc=new Document();
    doc.add(new LongField("id", 1, Store.YES));
    doc.add(new TextField("title", "如何学习lucene", Store.YES));
    doc.add(new TextField("content", "掌握原理,熟悉API,多看文档", Store.YES));
    Directory dir=new FSDirectory.**open**(new File("D:\\index"));//open()类没有,写上就会报错

    Analyzer analyzer=new StandardAnalyzer(Version.LUCENE_46);
    IndexWriterConfig config=new IndexWriterConfig(Version.LUCENE_46, analyzer);
    IndexWriter index=new IndexWriter(dir, config);
    index.addDocument(doc);
    index.close();
}

}

  • 写回答

2条回答 默认 最新

  • zqbnqsdsmd 2018-06-19 15:52
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀