FlexibleSearchQuery响应无数据 [英] FlexibleSearchQuery response no data
问题描述
我正在尝试使用FlexibleSearchQuery
获取一些数据,但它正在响应空结果.如果将查询设置为hac>Console>Flexible Search
,则可以获得所需的数据.
这是我在Java文件中编写查询的方式.
I am trying to get some data using FlexibleSearchQuery
but it is responding empty result. If I set this query hac>Console>Flexible Search
I can get the data I am looking for.
Here is how I am writing query in java file.
sb.append(" SELECT {p:pk} ");
sb.append(" FROM {" + ProductModel._TYPECODE + " AS p} ");
sb.append(" WHERE {p:" + ProductModel.PK + " } IN ({{");
sb.append(" SELECT DISTINCT {pro:" + ProductModel.PK + "} ");
sb.append(" FROM {CategoryProductRelation AS cp},{" + ProductModel._TYPECODE + "! AS pro},{" + CategoryModel._TYPECODE
+ " AS c}");
sb.append(" WHERE {pro:" + ProductModel.PK + " } = {cp:target}");
sb.append(" AND {c:" + CategoryModel.PK + " } = {cp:source}");
sb.append(" AND {c:" + CategoryModel.CODE + " } !=?categoryCode }})");
args.put("categoryCode", categoryCode);
if (args != null && !args.isEmpty())
{
searchQuery.addQueryParameters(args);
}
这就是我所说的搜索
final FlexibleSearchQuery searchQuery = new FlexibleSearchQuery(sb.toString());
searchResult.getResult().size() >> retuns 0
如果我在控制台中输入
SELECT {p:pk} FROM { Product AS p} WHERE { p: pk } IN ({{
SELECT DISTINCT {pro: PK }
FROM
{CategoryProductRelation AS cp},
{Product AS pro},
{Category as c}
WHERE {pro: PK} = {cp:target}
AND {c:PK} = {cp:source}
AND {c:code} != '0101'}})
我知道
PK
8796093579265
8796101804033
8796100165633
8796098428929
8796093153281
8796102361089
8796097052673
8796093808641
8796093972481
8796096823297
我做错了什么? 控制台查询和字符串查询有什么区别吗?
What am I doing wrong? Is there any difference console query and string query?
推荐答案
根据您的定义,我认为您的问题与Restrections有关:限制是FlexibleSearch遵守的规则,该规则允许根据搜索类型限制搜索结果搜索以及当前登录的用户
I think that the problem in your case is related to Restrections, by definition : Restrictions are rules obeyed by FlexibleSearch which allow to limit search results depending on which type is searched and which user is currently logged in
因此请尝试在调用灵活搜索之前禁用搜索限制
so try to Disable search restrictions before calling your flexible seach
import de.hybris.platform.search.restriction.SearchRestrictionService;
...
// Disable search restrictions
searchRestrictionService.disableSearchRestrictions();
// some query goes here
// Enable search restrictions
searchRestrictionService.enableSearchRestrictions();
// some query goes here
另一方面,当您使用hac>Console>Flexible Search
时,我假设您以admin身份登录,因此默认情况下,在Hybris Flexible搜索中所有限制都处于禁用状态
In other hand , when you use hac>Console>Flexible Search
i suppose that you log as admin , so all restrictions are disabled by default in Hybris Flexible search
您可以搜索HMC中的所有活动限制,方法是搜索类型:SearchRestriction
,查看followinf屏幕截图
You can check all actives restrctions in HMC, by searchig the type : SearchRestriction
, look the followinf screenshot
请参阅: https://help.hybris.com/6.3.0 /hcd/8c428f8286691014970ceee87aa01605.html
这篇关于FlexibleSearchQuery响应无数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!