【问题标题】:unable to evaluate the expression method threw 'java.lang.illegalargumentexception' exception while excuting the flexible search query执行灵活搜索查询时无法评估表达式方法引发“java.lang.illegalargumentexception”异常
【发布时间】:2020-10-06 20:23:13
【问题描述】:

我在执行flexiblesearchservice.search(query)时从db获取产品详细信息,它抛出了这个错误。我的灵活搜索查询与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.

【问题讨论】:

    标签: mysql hybris flexible-search


    【解决方案1】:
    "where {os:code}='"+OrderStatus.COMPLETED +"'
    

    上面的代码可能是问题所在,OrderStatus.COMPLETED 返回一个对象,而不是String

    您可以将其作为查询参数传递。

    "where {os:code} = '" + OrderStatus.COMPLETED.getCode() +"'
    

    【讨论】:

      猜你喜欢
      • 2020-04-30
      • 2021-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多