Lucene的UpdateDocument
来源:互联网 发布:mac 覆盖重装系统 编辑:程序博客网 时间:2024/04/28 06:18
Lucene从根本上来讲,并不支持对Document的更新操作,它提供的UpdateDocument方法其实是先删除后新增。在实际使用过程中,发现该方法有如下限制:
1、设置的Term对应的Field必须是字符串类型
也就是如下的组合能正常执行:
Document document = new Document();document.Add(new Field("serviceid", serviceQueryResult.ServiceId.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));document.Add(new NumericField("shopid", Field.Store.YES, true).SetIntValue(serviceQueryResult.ShopId));document.Add(new Field("servicename", serviceQueryResult.ServiceName, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));writer.AddDocument(document);writer.UpdateDocument(new Term("serviceid", serviceQueryResult.ServiceId.ToString()), document);若serviceid是整型的,则不能直接用UpdateDocument方法来更新必须先删除后创建,如下:
Document document = new Document();document.Add(new NumericField("serviceid", Field.Store.YES, true).SetIntValue(serviceQueryResult.ServiceId));document.Add(new NumericField("shopid", Field.Store.YES, true).SetIntValue(serviceQueryResult.ShopId));document.Add(new Field("servicename", serviceQueryResult.ServiceName, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));writer.AddDocument(document);writer.DeleteDocuments(NumericRangeQuery.NewIntRange("serviceid", serviceQueryResult.ServiceId, serviceQueryResult.ServiceId, true, true));writer.AddDocument(document);
0 0
- Lucene的UpdateDocument
- 关于Lucene中的updateDocument()方法的使用
- Lucene IndexWriter updateDocument()过程源码详解
- [lucene]关于对xml的lucene索引
- Lucene学习笔记:Lucene的总体结构
- 【Lucene实战】Lucene的分析过程
- solr/lucene和nutch/lucene的区别
- lucene(一) lucene一些概念的理解
- 【Lucene】Lucene和Oracle数据库的对比
- .NET 的 Lucene
- lucene的首次应用
- Lucene的工作原理
- lucene的demo
- Lucene 的学习 【摘】
- Lucene的平行索引
- Lucene的平行索引
- Lucene 的学习
- Lucene 的学习
- 【C++】智能指针的实现
- android自定义UI模板图文详解
- cin流
- win8.1 无法安装 .net framework3.5 问题的解决方法
- 的反复改来付款了覆盖率
- Lucene的UpdateDocument
- Django静态文件配置
- c/c++下 long long与__int64不同编译环境的比较
- 到付件健康的房间卡发放
- java.lang.IllegalStateException解决办法
- 加载大图片到Android内存
- 不应该学太多
- UIViewController - View Management(视图管理)
- Android 属性动画(Property Animation) 完全解析 (下)