Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Get the "title" field from the "assetentry" table
Hello!
I want to make a query to the "assetentry" table, which will get all those records whose "title" field contains the word "Shared". I tried to get it, but can't find the way.
AssetEntryQuery x = new AssetEntryQuery();
x.setTitle("Shared");
List<AssetEntry> title = AssetEntryLocalServiceUtil.getEntries(x);
for(int i=0; i<title.size(); i++) {
System.out.println("Titulo " + i + ": " + title.get(i));
}
Thank you!
Regards!
I want to make a query to the "assetentry" table, which will get all those records whose "title" field contains the word "Shared". I tried to get it, but can't find the way.
AssetEntryQuery x = new AssetEntryQuery();
x.setTitle("Shared");
List<AssetEntry> title = AssetEntryLocalServiceUtil.getEntries(x);
for(int i=0; i<title.size(); i++) {
System.out.println("Titulo " + i + ": " + title.get(i));
}
Thank you!
Regards!
As far as I know there is no method to get Assets by title with a wildcard match.
Probably the best way to fulfil your requirement is to use Dynamic Queries: https://portal.liferay.dev/docs/7-2/appdev/-/knowledge_base/a/dynamic-query
Please note that asset title is multilanguage, so the field "title" contains an XML with all translations.
Probably the best way to fulfil your requirement is to use Dynamic Queries: https://portal.liferay.dev/docs/7-2/appdev/-/knowledge_base/a/dynamic-query
Please note that asset title is multilanguage, so the field "title" contains an XML with all translations.
Maybe you could use Elasticsearch instead? I mean, ES has indexed all assets and writing a custom query isn't really hard. Maybe something along the following lines could work:
SearchContext searchContext = new SearchContext();
searchContext.setCompanyId(companyId);
searchContext.setUserId(userId);
searchContext.setGroupIds(groupIds);
searchContext.setLocale(locale);
BooleanQuery query = new BooleanQueryImpl();
query.addTerm(Field.TITLE, keyword, true, BooleanClauseOccur.MUST);
// Add other filters to make the query more precise, e.g. to get rid of drafts and old versions: criteriaBuilder.addExactRequiredTerm(query, "head", "true"); Hits hits = indexSearcherHelper.search(searchContext, query);
SearchContext searchContext = new SearchContext();
searchContext.setCompanyId(companyId);
searchContext.setUserId(userId);
searchContext.setGroupIds(groupIds);
searchContext.setLocale(locale);
BooleanQuery query = new BooleanQueryImpl();
query.addTerm(Field.TITLE, keyword, true, BooleanClauseOccur.MUST);
// Add other filters to make the query more precise, e.g. to get rid of drafts and old versions: criteriaBuilder.addExactRequiredTerm(query, "head", "true"); Hits hits = indexSearcherHelper.search(searchContext, query);
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™