flexible search query returning zero results in DAO giving results in HAC

59 views Asked by At

I am using below flexible search query in my DAO class, it is giving zero results always. when I try it in the HAC it is giving results. it is only working for uk-availability and UK Price Group. I want this query to run for all countries for example for fi-availability and FI Price Group.

public List<ProductModel> getProductsByDateTimeRange(Date fromModifiedDate, Date toModifiedDate,BaseSiteModel site) {
        try {
            String siteid=site.getUid().split("-",2)[1];
            String siteId=siteid.toUpperCase();
    final FlexibleSearchQuery qar = new FlexibleSearchQuery(
                    "SELECT {" + ProductModel.PK + "} FROM {" + ProductModel._TYPECODE +
                            " as prod JOIN CatalogVersion AS cv ON {cv:pk} = {prod:catalogVersion} "+
                            "JOIN Catalog AS cat ON {cv:catalog} = {cat:pk} "+
                            "join articleapprovalstatus as st on {prod.approvalstatus}={st.pk} "+
                            "JOIN ProductAvailabilityAssignment as paa ON {paa:product} = {prod:pk} "+
                            "JOIN ProductAvailabilityGroup as pag ON {paa:availabilityGroup} = {pag:pk} " +
                            "JOIN PriceRow AS pricerow ON {pricerow:product} = {prod:pk} "+
                            "JOIN UserPriceGroup AS upg ON {pricerow:ug} = {upg:pk} "+
            "} WHERE {prod:" + ProductModel.MODIFIEDTIME + "} >= ?" + ProductModel.MODIFIEDTIME+
                            " AND {cat:name} = 'ResMed Product Catalog' AND {cv:version} = 'Online'"+
                            " AND {st:code}='approved' and {pag:id} = '" + siteid + "-availability' and {upg:name} = '"+ siteId +" Price Group' ");
            final Map<String, Object> params = new HashMap<String, Object>();
            params.put(ProductModel.MODIFIEDTIME, fromModifiedDate);
            qar.addQueryParameter(params); // Replace with the actual timestamp value
            List<ProductModel> ress=flexibleSearchService.<ProductModel> search(qar).getResult();
            for (ProductModel product : ress) {
                Date modifiedTime = product.getModifiedtime(); // Assuming there's a getter method for modifiedtime
                LOG.info("Trail PK: " + product.getCode() + ", Modified Time: " + modifiedTime);
            }
            return ress;
        }
        catch (Exception e){
            LOG.error(String.format("exception flexible search query",e.getMessage()));
        }
        return null;
    }
0

There are 0 answers