Shivam Aggarwal
Shivam Aggarwal

Reputation: 805

How can I search content in liferay using tags only(not when keyword is available within content)?

I am using Liferay 6.1.1.How can I search content in liferay using tags only(not when keyword is available within content).When I search for a keyword,the search looks for the keyword within title,content as well as tags for all asset types.All I want is to search a keyword,within tags of all asset types. Thanks in advance.

Upvotes: 1

Views: 1975

Answers (1)

Roberto Paolillo
Roberto Paolillo

Reputation: 121

The easy way is creating an your own search portlet that obtains a list of tag id from keywords, using AssetTagLocalServiceUtil.getTags if you want exact matches or a dynamicQuery with a "like" Restriction. Then:

AssetEntryQuery query = new AssetEntryQuery(); 
long[] tagIds = {array of tag ids obtained};  
query.setAnyTagIds(tagIds);
//OR: query.setAllTagIds(atagIds);
List<AssetEntry> results = AssetEntryLocalServiceUtil.getEntries(query);

Otherwise, you could try to use Faceted Search as described here: http://www.liferay.com/web/raymond.auge/blog/-/blogs/12917352#h.itt7gsmb81v4

Upvotes: 2

Related Questions