- package org.se.lucene;
- //主类
- import java.io.File;
- import java.io.IOException;
- import org.apache.lucene.analysis.standard.StandardAnalyzer;
- import org.apache.lucene.document.Document;
- import org.apache.lucene.document.Field;
- import org.apache.lucene.index.CorruptIndexException;
- import org.apache.lucene.index.IndexReader;
- import org.apache.lucene.index.IndexWriter;
- import org.apache.lucene.index.IndexWriterConfig;
- import org.apache.lucene.index.Term;
- import org.apache.lucene.store.Directory;
- import org.apache.lucene.store.FSDirectory;
- import org.apache.lucene.store.LockObtainFailedException;
- import org.apache.lucene.util.Version;
- public class lucene_index {
- private String[] ids={"1","2","3","4","5","6"};
- private String[] emails={"aa@aa.org","cc@cc.org","dd@@dd.org","bb@bb.org","ee@ee.org","ff@ff.org"};
- private String[] contents={"welcometotyu","hellowboy","higirl","howareyou","googluck","badgosh"};
- private int[] attachs={1,2,3,4,5,6};
- private String[] names={"liwu","zhangsan","xiaoqinag","laona","dabao","lisi"};
- private Directory directory=null;
- public lucene_index()
- {
- try {
- directory=FSDirectory.open(new File("f:/lucene/index02"));
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public void quary()
- {
- try {
- IndexReader reader=IndexReader.open(directory);
- System.out.println("numdocs"+reader.numDocs());
- System.out.println("maxDocs"+reader.maxDoc());
- System.out.println("detelemaxDocs"+reader.numDeletedDocs());
- reader.close();
- } catch (CorruptIndexException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- @SuppressWarnings("deprecation")
- public void undelete()
- {
- try {
- //回复时必须把reader的只读设为false
- IndexReader reader=IndexReader.open(directory,false);
- reader.undeleteAll();
- reader.close();
- } catch (CorruptIndexException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- //清空回收站,强制优化
- public void forceDelete()
- {
- IndexWriter writer=null;
- try {
- writer=new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_36,
- new StandardAnalyzer(Version.LUCENE_36)));
- //参数十一个选项,可以是一个query,也可以是一个term term就是一个精确查找的值
- //此时删除的文档并未完全删除,而是存储在回收站中,可以恢复的
- writer.forceMergeDeletes();
- } catch (CorruptIndexException e) {
- e.printStackTrace();
- } catch (LockObtainFailedException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- finally{
- if (writer!=null) {
- try {
- writer.close();
- } catch (CorruptIndexException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
- public void merge()
- {
- IndexWriter writer=null;
- try {
- writer=new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_36,
- new StandardAnalyzer(Version.LUCENE_36)));
- writer.forceMerge(2);
- } catch (CorruptIndexException e) {
- e.printStackTrace();
- } catch (LockObtainFailedException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- finally{
- if (writer!=null) {
- try {
- writer.close();
- } catch (CorruptIndexException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
- public void delete()
- {
- IndexWriter writer=null;
- try {
- writer=new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_36,
- new StandardAnalyzer(Version.LUCENE_36)));
- //参数十一个选项,可以是一个query,也可以是一个term term就是一个精确查找的值
- //此时删除的文档并未完全删除,而是存储在回收站中,可以恢复的
- writer.deleteDocuments(new Term("id","1"));
- } catch (CorruptIndexException e) {
- e.printStackTrace();
- } catch (LockObtainFailedException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- finally{
- if (writer!=null) {
- try {
- writer.close();
- } catch (CorruptIndexException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
- public void index()
- {
- IndexWriter writer=null;
- Document doc=null;
- try {
- writer =new IndexWriter(directory,new IndexWriterConfig(Version.LUCENE_36,
- new StandardAnalyzer(Version.LUCENE_36)));
- //writer.deleteAll();
- for(int i=0;i<ids.length;i++)
- {
- doc=new Document();
- doc.add(new Field("id",ids[i],Field.Store.YES,Field.Index.NOT_ANALYZED_NO_NORMS));
- doc.add(new Field("emails",emails[i],Field.Store.YES,Field.Index.NOT_ANALYZED));
- doc.add(new Field("contents",contents[i],Field.Store.YES,Field.Index.ANALYZED));
- doc.add(new Field("name",names[i],Field.Store.YES,Field.Index.NOT_ANALYZED_NO_NORMS));
- writer.addDocument(doc);
- }
- } catch (CorruptIndexException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (LockObtainFailedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- finally{
- if(writer!=null)
- {
- try {
- writer.close();
- } catch (CorruptIndexException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
- //更新索引
- public void update()
- {
- /*lucene本身不支持更新
- *
- * 通过删除索引然后再建立索引来更新
- */
- IndexWriter writer=null;
- Document doc=null;
- try {
- writer =new IndexWriter(directory,new IndexWriterConfig(Version.LUCENE_36,
- new StandardAnalyzer(Version.LUCENE_36)));
- writer.deleteAll();
- for(int i=0;i<ids.length;i++)
- {
- doc=new Document();
- doc.add(new Field("id",ids[i],Field.Store.YES,Field.Index.NOT_ANALYZED_NO_NORMS));
- doc.add(new Field("emails",emails[i],Field.Store.YES,Field.Index.NOT_ANALYZED));
- doc.add(new Field("contents",contents[i],Field.Store.YES,Field.Index.ANALYZED));
- doc.add(new Field("name",names[i],Field.Store.YES,Field.Index.NOT_ANALYZED_NO_NORMS));
- writer.updateDocument(new Term("id","1"), doc);
- }
- } catch (CorruptIndexException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (LockObtainFailedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- finally{
- if(writer!=null)
- {
- try {
- writer.close();
- } catch (CorruptIndexException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
- }
- //测试类
- package org.se.lucene;
- import org.junit.Test;
- public class test {
- @Test
- public void testIndex()
- {
- lucene_index l_index=new lucene_index();
- l_index.index();
- }
- @Test
- public void testquary()
- {
- lucene_index l_index=new lucene_index();
- l_index.quary();
- }
- @Test
- public void testDelete()
- {
- lucene_index l_index=new lucene_index();
- l_index.delete();
- }
- @Test
- public void testunDelete()
- {
- lucene_index l_index=new lucene_index();
- l_index.undelete();
- }
- @Test
- public void testForceDelete()
- {
- lucene_index l_index=new lucene_index();
- l_index.forceDelete();
- }
- @Test
- public void testmerge()
- {
- lucene_index l_index=new lucene_index();
- l_index.merge();
- }
- @Test
- public void upDate()
- {
- lucene_index l_index=new lucene_index();
- l_index.update();
- }
- }
相关推荐
5G NR 双连接与载波聚合:PCell、SCell、PScell、SpCell 角色全解析
本文全面解析了5G NR中双连接与载波聚合技术的关键概念,详细介绍了PCell、SCell、PScell和SpCell的角色与功能。通过实际案例和配置示例,帮助读者理解这些小区在提升网络覆盖和速率方面的作用,以及在实际组网中的优化策略。
Luence建索中的一个异常
异常:org.apache.lucene.index.CorruptIndexException: failed to locate current segments_N file at org.apache.lucene.index.IndexFileDeleter.<init>(IndexFileDeleter.java:223) at org.apache.lucene.in...
scratch lenet(4): 开根号的C语言实现
使用C语言,分别使用二分法、牛顿法、卡马克快速法,求解正实数的开根号。包括公式推导、代码实现、运行结果,不使用任何第三方库和C标准库的数学库。
elasticsearch7.5.1集群断电故障解决方案
错误信息如下 { "state": "UNASSIGNED", "primary": true, "node": null, "relocating_node": null, "shard": 3, "index": "device_search_20201204", "recovery_source": { "type": "EXISTING_STORE","bootstrap_new_history_uuid": false}, "unassigned_info": { "reason": "ALLOC
【全网最新】使用 1panel面板 部署若依系统( springboot 和 vue)项目
打开前端项目的vue.config.js文件,检查devServer下的proxy代理部分,然后将下面这个端口修改为你要在打包后访问的端口,即使用nginx代理前的接口。这个端口默认是80端口,这里把其修改为不会冲突的8010端口,后台接口的地址配置为9080,不过感觉这里设置的8010和9080可能没有用,因为部署前端静态页面是,也配置了一次网页的外部接口和api的接口,后期有空了再验证。打开右侧的Maven,点击:生存期->package,然后点击运行,等待打包成功,包在如图所示的文件夹中。
Tushare Pro的安装使用——“抱歉,您没有访问该接口的权限,权限的具体详情访问:https://tushare.pro/document/1?doc_id=108”问题
最近做毕设关于量化交易的, 因此一直使用tushare作数据源,但是过程中到一些问题,因此这里写篇文章,供大家一起交流下。 Tushare简介 Tushare是一个免费、开源的python财经数据接口包。拥有如股票、基金、期货等行情数据,公司财务、基金经理等基本面数据,以及债券、外汇、行业、大数据、区块链。Tushare返回的绝大部分的数据格式都是pandas DataFrame类型,因此非常方便...
智能查询功能lucene使用情况及遇到的问题
[color=orange][/color]系统智能查询功能lucene使用情况及遇到的问题 根据客户反映我们要实现的搜索功能。 【范例】 • 【自然语查询】输入「百草」,可以查到「百草路」 • 【同音字查询】输入「白超路」,可以查到「百草路」 第一. 自然语句查询。 这是lucene大众化的搜索功能,但是单纯使用lucene官方包内的提供中文分词器,不能很好的实现我们需
一定能解决ROS系统 rosdep update超时问题de简单方法
rosdep update命令使用 1.首先将下面仓库的内容clone到本地 git clone https://github.com/ros/rosdistro.git 记录rosdistro存放地址,例如/home/gec/rosdistro 如果是自己的改成/home/user/rosdistro,其中user表示用户名 2.修改/usr/lib/python2/dist-packages/rosdep2/rep3.py文件 cd /usr/lib/python2/dist-packages/ros
Lucene小练三——索引删除,恢复,更新
package org.se.lucene; //主类 import java.io.File; import java.io.IOException; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache...
出现 RuntimeError: adaptive_avg_pool2d_backward_cuda does not have a deterministic implementation的解决方法
大致就是在执行主函数的训练函数中,在反向传播这一块出现了问题。解决方法就是添加如下代码块。找到提示bug的行数。
【ODX介绍】-4.2-UDS诊断$27服务在ODX-D诊断描述文件中如何描述
共25页精讲:附ODX-D XML:UDS $27 Security服务0x61和0x62 Sub-Function,其它Sub-Function可参照其格式。 目录 1 ODX-D描述一个UDS $27 Security服务Sub-Function的结构 2 标签DIAG-SERVICE描述的内容 2.1 举例:DIAG-SERVICE的XML描述 3 标签REQUEST描述的内容 3.1 举例:REQUEST的XML描述 4 标签POS-RESPONSE描述的内容 4.1 举例:PO..
Lucene索引删除、更新、恢复和加权操作
Lucene索引删除、更新、恢复和加权操作
Python 爬虫 + 数据分析:社会调查数据抓取与结果可视化分析
在当今数字化时代,数据已成为推动社会发展的关键资源之一。无论是市场调研、学术研究还是政策制定,社会调查数据都扮演着至关重要的角色。通过 Python 爬虫技术,我们可以高效地获取这些数据,并结合数据分析与可视化工具,深入挖掘数据背后的价值。本文将通过一个完整的实战项目,带你掌握如何使用 Python 爬虫抓取社会调查数据,并进行可视化分析。
Lucene中索引的删除,更新与查找以及恢复(lucene3.5)
package org.itat.text1; import java.io.File; import java.io.IOException; import javax.management.Query; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document
温度PID控制PLC程序
温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
Lucene笔记04-Lucene索引的删除与更新
一、删除索引 public void delete() { IndexWriter indexWriter = null; try { indexWriter = new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_35, new StandardAnalyzer(Version.LUC...
SIMATIC S7-1200, S7-1500 PID 控制[手册]
SIMATIC S7-1200, S7-1500 PID 控制[手册]
lucene-索引文档的删除、更新及增强加权
1、删除1)使用IndexReader类实现,这个类并没有立即从索引中删除文档,而只是在这些文档上加一个删除标记,直到IndexReader调用close()后才真正将它们删除。2)maxDoc()返回下一个可得到的文档的内部编号。numDocs()返回索引中的文档数量。 文档编号从0开始3)public class DocumentDeleteTest extends
VB摄像头监控
该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制
Lucene入门之索引的管理
Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE
Lucene3.5 之 索引删除和更新
package com.ethan.index; import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apach
索引的删除和更新
【删除索引】 1 /** 2 * 测试删除索引 3 */ 4 @Test 5 public void testDelete(){ 6 IndexWriter writer = null; 7 8 try { 9 //1、创建D...
4、学习Lucene3.5之索引删除、更新
(1)删除索引 /** * 删除索引 */ public void deleteIndex(){ IndexWriter indexWriter = createIndexWriter(); /** * deleteDocuments()参数解析: * 第一种:Term term 删除特定的索引(
Lucene3.5 的索引的创建,删除,更新,加权
==注意:在涉及到删除,更改之类的改变索引的操作时,要先重新创建一遍索引,然后再执行相关方法才可以看到效果,否则索引仍然是之前的 1. 索引的创建 (1). 第一步先创建模拟的内容,用于创建索引 private String[] ids = {"1","2","3","4","5"}; private String[] names = {"zhi","dan","feng","zhida
Lucene教程(四) 索引的更新和删除
这篇文章是基于上一篇文章来写的,使用的是IndexUtil类,下面的例子不在贴出整个类的内容,只贴出具体的方法内容。 3.5版本: 先写了一个check()方法来查看索引文件的变化: /** * 检查一下索引文件 */ public static void check() { IndexReader indexReader = null;
索引维护
索引维护 1. 删除索引 1.1删除指定索引 根据Term项删除索引,满足条件的将全部删除。 @Test public void testIndexDelete() throws Exception { // 创建Directory流对象 Analyzer analyzer = new IKAnalyzer(); Directory directory = ...
Lucene索引操作,删除,更新,优化
IndexUtil.java import java.io.File; import java.io.IOException; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.docum
373



被折叠的 条评论
为什么被折叠?



