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: DDMFormInstanceRecord Search Problem
HI,ALL.
I use BooleanQuery for DDMFormInstanceRecord Search. It works well when keywords is English, and do not return expected results when keywords is Chinese.
At the same time, the returned result automatically filters the groupID, how can I get all the results, not the records in a group.
How to solve the above two problems.
Thanks
I use BooleanQuery for DDMFormInstanceRecord Search. It works well when keywords is English, and do not return expected results when keywords is Chinese.
At the same time, the returned result automatically filters the groupID, how can I get all the results, not the records in a group.
How to solve the above two problems.
Thanks
protected void setDDMFormInstanceRecordSearchResults(
FormInstanceRecordSearch formInstanceRecordSearch) {
List<ddmforminstancerecord> results = null;
int status = WorkflowConstants.STATUS_ANY;
SearchContext searchContext = getSearchContext(status);
BooleanQuery booleanQuery = new BooleanQueryImpl();
try {
addExactRequiredTerm(booleanQuery,Field.STATUS, String.valueOf(WorkflowConstants.STATUS_APPROVED));
addExactRequiredTerm(booleanQuery,"ddm__keyword__89173__campanyeurDKk_zh_CN", "shanghai"); // return expected results:)
addExactRequiredTerm(booleanQuery,"ddm__keyword__89173__campanyeurDKk_zh_CN", "上海"); // DO NOT return expected results:(
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BooleanClause booleanClause = BooleanClauseFactoryUtil.create(
booleanQuery, BooleanClauseOccur.MUST.getName());
searchContext.setBooleanClauses(new BooleanClause[] {booleanClause});
BaseModelSearchResult<ddmforminstancerecord> baseModelSearchResult =
_ddmFormInstanceRecordLocalService.searchFormInstanceRecords(
searchContext);
results = baseModelSearchResult.getBaseModels();
formInstanceRecordSearch.setResults(results);
}
protected void addExactRequiredTerm(BooleanQuery query,String field,String value)throws ParseException {
TermQueryImpl termQuery = new TermQueryImpl(new QueryTermImpl(field,value));
query.add(termQuery,BooleanClauseOccur.MUST);
}
protected SearchContext getSearchContext(int status) {
SearchContext searchContext = SearchContextFactory.getInstance(
PortalUtil.getHttpServletRequest(_renderRequest));
searchContext.setAttribute(Field.STATUS, status);
searchContext.setAttribute(
"formInstanceId", _ddmFormInstance.getFormInstanceId());
searchContext.setEnd(searchContext.getEnd());
searchContext.setKeywords(getKeywords());
searchContext.setStart(searchContext.getStart());
return searchContext;
}
</ddmforminstancerecord></ddmforminstancerecord>
I have solved this problem.
In the build.gradle, add the code.
hope to help someone in need.
In the build.gradle, add the code.
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
hope to help someone in need.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™