标签:rdf tga ng2 eol hl7 orb aaa ps1 xls
// public IndexWriter getIndexWriter() throws Exception{ // 第一步:创建一个java工程,并导入jar包。 // 第二步:创建一个indexwriter对象。 Directory directory = FSDirectory.open(new File("E:\\lucene&solr\\index")); // Directory directory = new RAMDirectory();//保存索引到内存中 (内存索引库) Analyzer analyzer = new StandardAnalyzer();// 官方推荐 IndexWriterConfig config = new IndexWriterConfig(Version.LATEST, analyzer); return new IndexWriter(directory, config); }
1 //全删除 2 @Test 3 public void testAllDelete() throws Exception { 4 IndexWriter indexWriter = getIndexWriter(); 5 indexWriter.deleteAll(); 6 indexWriter.close(); 7 }
结果:
先创建索引:
删除索引
//根据条件删除 @Test public void testDelete() throws Exception { IndexWriter indexWriter = getIndexWriter(); Query query = new TermQuery(new Term("fileName","springmvc")); indexWriter.deleteDocuments(query); indexWriter.close(); }
结果:
第三个文档被删除,第五个文档被删除。
标签:rdf tga ng2 eol hl7 orb aaa ps1 xls
原文地址:http://www.cnblogs.com/qlqwjy/p/7291185.html