hai我在执行flexiblesearchservice时从db获取产品详细信息。search(query(它抛出了这个错误。我的灵活搜索查询在hac中运行良好。但从灵活的搜索服务中抛出错误。我的查询和服务如下所示。
"({{select {p:"+ProductModel.PK+"} from { "+ OrderModel._TYPECODE +" as o " +
" join "+ OrderStatus._TYPECODE+" as os on {os:pk} = {o:"+OrderModel.STATUS+"}"+
" join "+ OrderEntryModel._TYPECODE +" as oe on {oe:"+ OrderEntryModel.ORDER +"} = {o:"+OrderModel.PK+"}"+
" join "+ ProductModel._TYPECODE +" as p on {oe:"+OrderEntryModel.PRODUCT+"} = {p:"+ProductModel.PK+"}"+
" join "+ CatalogVersionModel._TYPECODE+" as cv on { p:"+ProductModel.CATALOGVERSION +"} = {cv:"+CatalogVersionModel.PK+"}"+
" join "+ CatalogModel._TYPECODE +" as c on {p:"+ProductModel.CATALOG+"} = {c:"+CatalogModel.PK+"}} "+
"where {os:code}='"+OrderStatus.COMPLETED +"' and {"+OrderModel.DATE+"}>'2017-08-16 00:00:00.000' " +
"and {"+OrderModel.DATE+"}<'2020-09-30 00:00:00.000' " +
"and {cv:"+CatalogVersionModel.VERSION+"}= 'Online' " +
"and {c:"+CatalogModel.ID+"} like 'apparelProductCatalog' " +
"group by {p:"+ProductModel.PK+"} order by sum({oe:"+OrderEntryModel.QUANTITY+"}) desc" +
" limit 10 }})";
final FlexibleSearchQuery fQuery = new FlexibleSearchQuery(QUERY);
fQuery.setResultClassList(Arrays.asList(ProductModel.class));
final SearchResult<ProductModel> searchResult =flexibleSearchService.search(fQuery);
final List<ProductModel> productModelList= searchResult.getResult();```
**error:** unable to evaluate the expression method threw 'java.lang.illegalargumentexception' exception
please help me out.
"where {os:code}='"+OrderStatus.COMPLETED +"'
以上代码可能是问题所在,OrderStatus.COMPLETED
返回一个对象,而不是String
。
您可以将其作为查询参数传递。
"where {os:code} = '" + OrderStatus.COMPLETED.getCode() +"'