Saturday, February 3, 2018

Lucene Search in Liferay


Today we will see how to use Lucene Search in Liferay. For this i create a simple portlet which can search journal Articles on the basis of title.

So lets start this Step by Step:-

Step 1:-Create a project and portlet
Create a project and then create a portlet in it .Here my project name is  lucene-portlet and portlet name is Demo






Step 2:-Change the jsp
Change your view.jsp as:-

view.jsp



Explanation:-
Here i create a simple form with only one text field and a submit button. By using the text field we send the keyword for search.



Step 3:-Change the Controller
Now change your Demo.java:-

Demo.java


Explanation:-
Here i use Boolean Query and apply some conditions like:-
1)line 28 :- Search on JournalArticle class
2)line 29 :- Title must match with the Keyword.
3)line 30 :- Fetch only Latest Articles.






Step 4:-Check the Output

Now deploy the portlet and check the output . When you enter some text in text box it will get the articles that contain the required title.

You can download the source code from here.


Hope this will Help....

Related Post:-

Liferay Portlet URL in JavaScript

No comments:

Post a Comment

Total Pageviews

Number Of Unique Visitor

Free counters!