新加入到了公司的门户组,在使用LifeRay的搜索,检索新闻时只能通过标题和正文来检索,现在需要对其进行扩展,让其支持摘要、新闻采编者、新闻原作者等的检索。
修改方法如下:
LifeRay版本:4.2.2(公司的项目,前期采用的这个版本,修改太多,难以升级了~)
涉及修改的类:
com.liferay.portal.lucene.LuceneFields
com.liferay.portlet.journal.util.Indexer
com.liferay.portlet.journal.service.impl.JournalArticleServiceImpl
com.liferay.portal.service.impl.CompanyLocalServiceImpl
建立索引
首先在com.liferay.portlet.journal.util.Indexer类addArticle()方法中可以看到,Liferay索引了哪些字段,从中不难看出Liferay索引了标题、正文和摘要
doc.add(LuceneFields.getText(LuceneFields.TITLE, title));
doc.add(LuceneFields.getText(LuceneFields.CONTENT, content));
doc.add(LuceneFields.getText(LuceneFields.DESCRIPTION, description));
我们新增采编者,原作者的索引
doc.add(LuceneFields.getText(LuceneFields.USER_NAME, userName));
doc.add(LuceneFields.getText(LuceneFields.AUTHOR_SHIP, authorShip));
同时需要在LuceneFields中增相应的字段,这里不再具体写。
方法中的userName和authorShip在方法addArticle()中新增相应的引用即可,同时在com.liferay.portlet.journal.service.impl.JournalArticleServiceImpl类中新增相应的参数(根据Eclipse的错误提示修改即可)
修改检索内容
找到com.liferay.portal.service.impl.CompanyLocalServiceImpl中的public Hits search(String companyId,String portletId, String groupId, String type, String keywords)方法
可以看到这里在检索是只检索了标题和正文
LuceneUtil.addTerm(searchQuery, LuceneFields.TITLE, keywords);
LuceneUtil.addTerm(searchQuery, LuceneFields.CONTENT, keywords);
在这里加入我们需要检索的采编者、原作者、摘要
LuceneUtil.addTerm(searchQuery, LuceneFields.USER_NAME, keywords);
LuceneUtil.addTerm(searchQuery, LuceneFields.AUTHOR_SHIP, keywords);
LuceneUtil.addTerm(searchQuery, LuceneFields.DESCRIPTION, keywords);
到此就修改完成,在portal-ejb下面执行ant deploy,重新运行服务器,新的检索即可使用。
分享到:
相关推荐
liferay产品(概述、功能、益处)。写方案用
Liferay Portal Liferay IDE
liferay portal 开发指南liferay portal 开发指南liferay portal 开发指南liferay portal 开发指南
Liferay中的AUI框架,官方叫做Alloy,是一个UI超框架,能为浏览器的三方面,结构,风格和表现建立网络应用提供连续的简单的API。 它融合了三种设计语言:HTML, CSS 和 JAVA。 准确来说AUI是Liferay在YUI的基础上...
liferay 超级学习文档 liferay 框架 java hibernate liferay 不用多说
liferay 二次开文档
Liferay Web内容管理指南Liferay
打开Liferay IDE,Window-->Preferences-->Server-->Runtime Environment,点击右边Add…,在弹出的服务器选择里面选择Liferay,Inc-->Liferay v6.1 CE (Tomcat 7),请打“Create a new location server”打上勾。...
liferay tune
Liferay 6 入门教程
Liferay教程
Liferay Themes[1].pdf Liferay+CMS系统培训.ppt Liferay+Portal+数据库介绍+.doc Liferay+权限管理.doc liferay-portal-5-2-systems-development-sample-chapter-5-managing-pages[1].pdf ...
liferay6.2开发指南liferay6.2开发指南.doc
liferay快速入门quickstart
liferay文档 给初学liferay的人
Liferay is a different portal. 10分下载的, 打包5折提供下载. Part 1 Introduction to Liferay 1. Liferay is a different portal 2. Getting started with the Liferay development platform Part 2 Adding ...
Liferay 是一个完整的门户解决方案,基于J2EE的应用,使用了EJB以及JMS等技术,前台界面部分使用Struts MVC 框架,基于XML的portlet配置文件可以自由地动态扩展,使用了Web服务来支持一些远程信息的获取,使用 ...
liferay portlet form 机制
liferay6.06学习手册 Liferay Portal6.0.6学习笔记
这是本人工作了2年有关liferay中的所有技术详细日记 很珍贵