问题描述
SAP 商务 1905
我应该启用哪个包(到 DEBUG 或 INFO)来在 tomcat 日志或控制台中记录 Solr 查询?
我知道您可以在 hybris/log/solr 下看到查询,但我也想在控制台运行时看到查询。
解决方法
Hybris OOB 支持该功能,它将为您提供从 Hybris 到 Solr 服务器的完整查询。
这个类(de.hybris.platform.solrfacetsearch.search.context.listeners.SolrQueryDebuggingListener)会给你原始查询、解析的 Solr 查询、过滤查询和 Solr 查询解释(如果你是使用任何配置,如 score、boost、fieldweight)。
如何启用它:-->
转到 SolrFacetSearchConfig--> 并将此侦听器 solrQueryDebuggingListener 添加到侦听器列表中。
Hybris 控制台日志::
INFO [hybrisHTTP16] [SolrQueryDebuggingListener] Raw Query: {!boost}(+{!lucene v=$yq})
INFO [hybrisHTTP16] [SolrQueryDebuggingListener] Parsed Solr Query: +(DisjunctionMaxQuery(((variants_string_mv:0001)^20.0 | (ean_string:0001)^100.0 | (variantsSupercategory_text_zz_mv:0001)^50.0 | (keywords_text_zz:0001)^50.0 | (name_text_zz:0001)^90.0 | (code_string:0001)^90.0 | (categoryName_text_zz_mv:0001)^50.0 | (alias_string:0001)^90.0)) DisjunctionMaxQuery((variants_string_mv:0001* | variantsSupercategory_text_zz_mv:0001* | (name_text_zz:*0001*)^150.0 | (code_string:0001*)^45.0)) DisjunctionMaxQuery(((variants_string_mv:0001)^40.0 | (variantsSupercategory_text_zz_mv:0001)^40.0 | (name_text_zz:0001)^100.0)) DisjunctionMaxQuery(((name_text_zz:0001~1)^-1.0)))
INFO [hybrisHTTP16] [SolrQueryDebuggingListener] Filter Queries: [sopOnly_boolean:false,((soldIndividually_boolean:tzze) AND (testOrderable_boolean:tzze) AND (testSample_boolean:false) AND (yyyIsProductVisible_warehouse_xxx_boolean:tzze) AND (yyyAvailableToSellByDate_warehouse_xxx_boolean:tzze) AND ((((*:* -bundleOnlineFrom_date:*) OR (bundleOnlineFrom_date:[* TO 2021-05-13T15:09:36.856Z])) AND ((*:* -bundleOnlineTo_date:*) OR (bundleOnlineTo_date:[2021-05-13T15:09:36.857Z TO *]))) OR (((categoryName_text_en_mv:*) OR (brandName_text_en_mv:*)) AND ((*:* -productCategoryOnlineFrom_date:*) OR (productCategoryOnlineFrom_date:[* TO 2021-05-13T15:09:36.856Z])) AND ((*:* -productCategoryOnlineTo_date:*) OR (productCategoryOnlineTo_date:[2021-05-13T15:09:36.857Z TO *])) AND ((*:* -productOnlineFrom_date:*) OR (productOnlineFrom_date:[* TO 2021-05-13T15:09:36.856Z])) AND ((*:* -productOnlineTo_date:*) OR (productOnlineTo_date:[2021-05-13T15:09:36.857Z TO *]))))),((stockQuantity_warehouse_xxx_long:* OR variants_string_mv:*)),((stockQuantity_warehouse_xxx_long:* OR variantsSupercategory_text_en_mv:*)),(-restrictedTiers_string_mv:400),((*:* NOT allowedUserGroups_string_mv:*) OR (allowedUserGroups_string_mv:(TP-zzS-AAA OR cls_dc9 OR testcustomergroup OR act_dst OR system_lom3 OR Twelve Percent OR test_AAA OR Nine Percent Award OR customergroup OR lge_ind))),((*:* NOT allowedProductUserGroups_string_mv:*) OR (allowedProductUserGroups_string_mv:(TP-DDD-AAA OR cls_dc9 OR testcustomergroup OR act_dst OR system_lom3 OR Twelve Percent OR test_AAA OR Nine Percent Award OR customergroup OR lge_ind))),(allowedProductCategoryUserGroups_string_mv:(TP-DDD-AAA OR cls_dc9 OR testcustomergroup OR act_dst OR system_lom3 OR Twelve Percent OR test_AAA OR Nine Percent Award OR customergroup OR lge_ind)),((isVariantProduct_boolean:false AND NOT testType_string:GROUP) OR {!parent which=(isVariantProduct_boolean:false) v=$childquery}),(catalogId:"ProductCatalog" AND catalogVersion:"Online"),priceValue_DDD-AAA_zzb_double:[0 TO *],priceStartTime_DDD-AAA_zzb_date:[* TO NOW],priceEndTime_DDD-AAA_zzb_date:[NOW TO *],-stockStatus_warehouse_xxx_string:noLongerAvailable]
INFO [hybrisHTTP16] [SolrQueryDebuggingListener] Solr Query explanation: {ProductCatalog/Online/E0001RK=
90.0 = sum of:
90.0 = max of:
90.0 = weight(alias_string:0001 in 737) [SchemaSimilarity],result of:
90.0 = score(doc=737,freq=1.0),product of:
90.0 = boost
1.0 = fieldWeight in 737,product of:
1.0 = tf(freq=1.0),with freq of:
1.0 = termFreq=1.0
1.0 = idf,computed as log((docCount+1)/(docFreq+1)) + 1 from:
2.0 = docFreq
1621.0 = docCount
1.0 = fieldNorm(doc=737)
}
,
在 local.properties/任何属性文件中添加以下记录器语句。
log4j2.logger.DefaultFacetSearchStrategy.name = de.hybris.platform.solrfacetsearch.search.impl.DefaultFacetSearchStrategy log4j2.logger.DefaultFacetSearchStrategy.level = DEBUG log4j2.logger.DefaultFacetSearchStrategy.appenderRef.stdout.ref = STDOUT
,包或类是 de.hybris.platform.solrfacetsearch.search.impl.DefaultFacetSearchStrategy
。