`
houzhaowei
  • 浏览: 492952 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

cannot make any changes to the index (it was opened with readOnly = true)

 
阅读更多

此异常为用IndexReader 删除索引所报的错。

异常原因:如异常所说:index 是以只读方式打开的,不可写。

解决方案:

IndexReader indexReader = IndexReader.open(FSDirectory.open(indexPath),false);

 

在打开IndexReader时 open 方法里多传一个参数并设置为false。 此参数即为 Readonly。

分享到:
评论
1 楼 randychao2008 2011-03-02  
@Test
private static void buildIndex() throws IOException {
File file = new File("c:\\index");

Directory indexDir = FSDirectory.open(file);//存储到磁盘
IndexWriter write = new IndexWriter(indexDir,new StandardAnalyzer(Version.LUCENE_30),true,MaxFieldLength.LIMITED);

for(int i =0;i<10;i++){
Document doc = new Document();
doc.add(new Field("content","word",Store.YES,Index.ANALYZED));
doc.add(new Field("name","doc",Store.YES,Index.ANALYZED));
write.addDocument(doc);
write.close();
}
}
请问 Document doc = new Document();应该写在循环体内还是循环体外;因为我用Luke查看了两种情况,出现不同的显示。有什么区别呢?谢谢

相关推荐

    .NET中TextBox控件设置ReadOnly=true后台取不到值三种解决方法

    当TextBox设置了ReadOnly=”true” 后,要是在前台为控件添加了值,后台是取不到的,值为“空” 原理没想通,说不清楚微软是出于什么考虑的,不过有时是要我们能通过前台脚本来填充值,并不希望用户修改其控件内容,...

    VclZip pro v3.10.1

    This was due to a problem where it would be freed automatically if there was a problem with the ArchiveStream when trying to open it as a zip file (possibly corrupt). Best practice is that ...

    asp.net TextBox控件设置ReadOnly后,不能回传。

    很奇怪,以前都没有过这样的怪问题,在别人机器上都能正常,想到可能和ASP.NET的版本... 解决的方法: &lt;asp id=”Username” runat=”server” ReadOnly=”True”&gt;&lt;/asp&gt; 去掉ReadOnly=”True”,改成 &lt;asp:textbox

    个人通讯录管理系统 vfp

    thisform.txt邮政编码.readonly=.f. thisform.txt性别.readonly=.f. thisform.txt手机.readonly=.f. thisform.txt小灵通.readonly=.f. thisform.txt住宅电话.readonly=.f. thisform.txtqq.readonly=.f. thisform....

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    Added TFlexFileFormat.StreamSupport property (default True), which difines, is it necessary to open file stream or give the file name only. - FIX: If the TCustomProp.Assign method calls when the ...

    图书管理系统 vfp

    thisform.txt邮政编码.readonly=.f. thisform.txt性别.readonly=.f. thisform.txt手机.readonly=.f. thisform.txt小灵通.readonly=.f. thisform.txt住宅电话.readonly=.f. thisform.txtqq.readonly=.f. thisform....

    基于jQuery的轻便版日期控件[可精确到分钟]

    input type=text maxlength="10" onfocus="jQuery(this).calendar()" readonly="true"/&gt;&lt;br/&gt; 显示日期时间: &lt;input type=text maxlength="16" onfocus="jQuery(this).calendar()" readonly="true"/&gt...

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令大全 ...telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss ... 各个 shell 可互相切换 ksh:$ sh:$ csh:guangzhou% bash:bash-3.00$ ... 命令和参数之间必需用空格隔...

    手动生成datagridview

    // Allow the user to edit the starting balance cell DataGridView1.Rows[0].ReadOnly = true; DataGridView1.Rows[0].Cells["Balance"].ReadOnly = false; // Autosize the columns. DataGridView1....

    JS中如何设置readOnly的值

    在网页中我们有时候需要控制文本输入框的...但是在JS中我们则不能食用txt_name.readonly=”readonly”来设置该属性,由于JS是区分大小写的,所以,在调用该属性的时候,我们必须使用txt_name.readOnly=true来设置。 当

    凭证管理系统(凭证管理系统)

    凭证管理系统 ... ReadOnly = True TabOrder = 1 TitleFont.Charset = DEFAULT_CHARSET TitleFont.Color = clBlue TitleFont.Height = -11 TitleFont.Name = 'MS Sans Serif' TitleFont.Style = []

    DevExpress VCL v2012 vol 1.6源码-例子-帮助-part2

    B218389 - Focus does not move to the previous/next row when it passes the first/last tile within the current row if a tile control's OptionsBehavior.FocusItemOnCycle property is set to True ...

    DevExpress VCL v2012 vol 1.6源码-例子-帮助-part1

    B218389 - Focus does not move to the previous/next row when it passes the first/last tile within the current row if a tile control's OptionsBehavior.FocusItemOnCycle property is set to True ...

    Javascript设置对象的ReadOnly属性(示例代码)

    在JS中ReadOnly属性比较奇怪,直接创建一个对象,给该对象赋值readonly属性不能够向HTML中一样使用下面的方式: 代码如下:var x=document.createElement(“input”);...x.readOnly=true;这个平时写JS时候

    DevExpress VCL v2012 vol 1.6源码、例子、帮助

    B218389 - Focus does not move to the previous/next row when it passes the first/last tile within the current row if a tile control's OptionsBehavior.FocusItemOnCycle property is set to True ...

    DevExpress VCL v2012 vol 1.6源码、例子、帮助-Part1

    B218389 - Focus does not move to the previous/next row when it passes the first/last tile within the current row if a tile control's OptionsBehavior.FocusItemOnCycle property is set to True ...

    DevExpress VCL 2012 vol 1.6源码、例子、帮助-Part2

    B218389 - Focus does not move to the previous/next row when it passes the first/last tile within the current row if a tile control's OptionsBehavior.FocusItemOnCycle property is set to True ...

    DevExpress VCL v2012 vol 1.6源码、例子、帮助-part2

    B218389 - Focus does not move to the previous/next row when it passes the first/last tile within the current row if a tile control's OptionsBehavior.FocusItemOnCycle property is set to True ...

    DevExpress VCL 2012 vol 1.6源码、例子、帮助-Part1

    B218389 - Focus does not move to the previous/next row when it passes the first/last tile within the current row if a tile control's OptionsBehavior.FocusItemOnCycle property is set to True ...

Global site tag (gtag.js) - Google Analytics