我应该启用哪个包来在 tomcat 日志或控制台中记录 Solr 查询?

Posted

技术标签:

【中文标题】我应该启用哪个包来在 tomcat 日志或控制台中记录 Solr 查询?【英文标题】:Which package should I enable to log the Solr query in the tomcat logs or the console? 【发布时间】:2021-08-03 19:10:31 【问题描述】:

SAP 商务 1905

我应该启用哪个包(到 DEBUG 或 INFO)以在 tomcat 日志或控制台中记录 Solr 查询?

我知道您可以在 hybris/log/solr 下看到该查询,但我也希望在控制台运行时看到该查询。

【问题讨论】:

【参考方案1】:

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)

【讨论】:

为“de.hybris.platform.solrfacetsearch.search.impl.DefaultFacetSearchStrategy”启用日志记录对我来说似乎足够了。但是,您的解决方案也很好。谢谢!【参考方案2】:

在 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

【讨论】:

【参考方案3】:

包或类是de.hybris.platform.solrfacetsearch.search.impl.DefaultFacetSearchStrategy

【讨论】:

以上是关于我应该启用哪个包来在 tomcat 日志或控制台中记录 Solr 查询?的主要内容,如果未能解决你的问题,请参考以下文章

我可以选择我在 Maven 依赖项中使用的唯一包来在 Eclipse 中导出可运行的 jar 吗?

我应该使用 TCP 还是 UDP 数据包来控制无人机?

GWT Framework 启用控制台日志

我应该使用啥 NPM 包来查找最近的城市。

哪个 jQuery/css 菜单库用于使用 ASP.NET TreeView 或菜单控件

在具有 Java 8 的嵌入式 Tomcat 8.5 上启用 TLS 握手的可观察性(日志记录/指标)