基于javaluncene的compass框架说明使用技术文档

上传人:Bod****ee 文档编号:47548044 上传时间:2018-07-02 格式:DOC 页数:29 大小:206.51KB
返回 下载 相关 举报
基于javaluncene的compass框架说明使用技术文档_第1页
第1页 / 共29页
基于javaluncene的compass框架说明使用技术文档_第2页
第2页 / 共29页
基于javaluncene的compass框架说明使用技术文档_第3页
第3页 / 共29页
基于javaluncene的compass框架说明使用技术文档_第4页
第4页 / 共29页
基于javaluncene的compass框架说明使用技术文档_第5页
第5页 / 共29页
点击查看更多>>
资源描述

《基于javaluncene的compass框架说明使用技术文档》由会员分享,可在线阅读,更多相关《基于javaluncene的compass框架说明使用技术文档(29页珍藏版)》请在金锄头文库上搜索。

1、Compass 技术文档技术文档目录目录一、原理描述:. 二、术语解释:. 三、下载地址:. 四、使用流程: . 五、基于 SSH 的 compass 的实例: 一、原理描述:一、原理描述:Compass 是一流的开放源码 JAVA 搜索引擎框架,对于你的应用修饰,搜 索引擎语义更具有能力。依靠顶级的 Lucene 搜索引擎,Compass 结合了,像 Hibernate 和 Spring 的流行的框架,为你的应用提供了从数据模型和数据源同 步改变的搜索力.并且添加了 2 方面的特征,事物管理和快速更新优化. Compass 的目标是:把 java 应用简单集成到搜索引擎中.编码更少,查找数

2、据更便捷 .二、术语解释:二、术语解释:名称描述LuceneApache Lucene 是一个基于 Java 全文搜索引擎,利用它可以轻易地 为 Java 软件加入全文搜寻功能。Lucene 的最主要工作是替文件的每一 个字作索引,索引让搜寻的效率比传统的逐字比较大大提高了,Lucene 提供一组解读,过滤,分析文件,编排和使用索引的提供一组解读,过 滤,分析文件,编排和使用索引的 API,它的强大之处除了高效和简单外, 是最重要的是使使用都是可以随时应自己需要自订其功能。开发者可以 把 Lucene 看成一个支持全文索引的数据库系统的.Compass我对 Compass 的定义是面向域模型域

3、模型的搜索框架, 面向域模型意味着必 须支持对对象的搜索,对持久化对象的搜索,和对 XML 文档对象的搜索, 同时还必须支持事务的处理,包括对创建,更新,保存,删除进行事务级别的 处理. 所以, Compass 是基于 Lucene, 高于 Lucene 的. 有个形象的比喻. Compass 对于 Lucene 就像 Hibernate 对于 JDBC,太有才了!Compass 的开 发路数完全参照 Hibernate.OSEM对象搜索引擎影射(Object Search Engine Mapping),通过 xml 配 置文件,提供了 POJOs (Plain Old Java Objec

4、ts)到搜索引擎.三、下载地址:三、下载地址:软件名称下载地址软件描述Compass 框架、jar 包http:/passfra mework.org/基于 Java 的搜索引擎四、使四、使用流程用流程:网络机器人程序www 文档网络机器人程序建立索引从数据库中搜索信息Tomcat 服务器JSP 索引数据库浏览器浏览器五、基于五、基于 SSH 的的 compass 的实例的实例:step1 在 ssh2 的基础上开发 加入 jar 包(compass-2.1.2.jar compass-index- patch.jar lucene-analyzers-2.4.0.jar lucene-cor

5、e-2.4.0.jar lucene-highlighter- 2.4.0.jar paoding-analysis.jar ) step2 先来看下实体 bean 的编写 Java 代码 1. package com.v512.example.model; 2. import pass.annotations.*; 3. /* 4. * Product entity. 5. * 6. * author MyEclipse Persistence Tools 7. */ 8. Searchable 9. public class Product implements java.io.Seria

6、lizable 10. 11. / Fields 12. 13. SearchableId 14. private String id; 15. SearchableProperty(name=“name“,index=Index.ANALYZED,store= Store.YES) 16. private String name; 17. SearchableProperty(name=“price“,index=Index.NOT_ANALYZED,s tore=Store.YES) 18. private Double price; 19. SearchableProperty(name

7、=“brand“,index=Index.ANALYZED,store =Store.YES) 20. private String brand; 21. SearchableProperty(name=“description“,index=Index.ANALYZED,s tore=Store.YES) 22. private String description; 23. 24. / Constructors 25. 26. /* default constructor */ 27. public Product() 28. 29. 30. /* full constructor */

8、31. public Product(String name, Double price, String brand, Str ing description) 32. this.name = name; 33. this.price = price; 34. this.brand = brand; 35. this.description = description; 36. 37. 38. / Property accessors 39. 40. public String getId() 41. return this.id; 42. 43. 44. public void setId(

9、String id) 45. this.id = id; 46. 47. 48. public String getName() 49. return this.name; 50. 51. 52. public void setName(String name) 53. this.name = name; 54. 55. 56. public Double getPrice() 57. return this.price; 58. 59. 60. public void setPrice(Double price) 61. this.price = price; 62. 63. 64. pub

10、lic String getBrand() 65. return this.brand; 66. 67. 68. public void setBrand(String brand) 69. this.brand = brand; 70. 71. 72. public String getDescription() 73. return this.description; 74. 75. 76. public void setDescription(String description) 77. this.description = description; 78. 79. 80. step3

11、 属性文件 Product.hbm.xml Java 代码 1. 2. 4. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 要使用 Compass 必须加入一个 applicationContext-compass.xml 文件,文件名 可以自行定义 这个就不用说了 废话 step4applicationContext-compass.xml: Java 代码 1. 2. 3. 7. 8. 9. 11. 12. 13. 14. 15. 16. 17. 18. classpath:com/v512/example/model 19. 20. 21. 22. 23. /lucene/indexes 24. 25. 26. 27. 28. 29. com.v512.example.model.Product 30. 31. 32. 34. 35. 36. 37. 38. 39. pa

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 学术论文 > 毕业论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号