简体   繁体   English

调试太阳黑子上的Solr搜索查询

[英]Debugging Solr search queries on Sunspot

How can I debug Solr search queries when using the Sunspot gem on Rails? 在Rails上使用Sunspot gem时,如何调试Solr搜索查询? I have some queries that are returning bizarrely high scores, and I'm trying to get to the bottom of why this is happening. 我有一些问题正在回归奇怪的高分,我正试图找到为什么会发生这种情况。

It doesn't seem like any debugging information is exposed to Sunspot, so I think that I need to debug through Solr directly. 似乎没有任何调试信息暴露给Sunspot,所以我认为我需要直接通过Solr进行调试。 Fortunately, Solr has a handy web interface to search from, but for some reason, any queries I enter there return with 0 results. 幸运的是,Solr有一个方便的Web界面可供搜索,但出于某种原因,我输入的任何查询返回0结果。

For example, when I search for the word "test" on my web app, it returns plenty of hits. 例如,当我在我的网络应用程序中搜索单词“test”时,它会返回大量的点击。 When I search for the same thing on the Solr admin interface this is what I get: 当我在Solr管理界面上搜索相同的东西时,这就是我得到的:

<response>
  <lst name="responseHeader">
    <int name="status">0</int>
    <int name="QTime">172</int>
    <lst name="params">
      <str name="explainOther"/>
      <str name="fl">*,score</str>
      <str name="indent">on</str>
      <str name="start">0</str>
      <str name="q">test</str>
      <str name="hl.fl"/>
      <str name="qt">standard</str>
      <str name="wt">standard</str>
      <str name="fq"/>
      <str name="version">2.2</str>
      <str name="rows">10</str>
    </lst>
  </lst>
  <result name="response" numFound="0" start="0" maxScore="0.0"/>
</response> 

If setting log_level to FINEST doesn't work, you should add this line to an initializer: 如果将log_level设置为FINEST不起作用,则应将此行添加到初始值设定项:

require "sunspot/rails/solr_logging"

source: http://outoftime.github.com/2010/03/03/sunspot-1-0.html 来源: http//outoftime.github.com/2010/03/03/sunspot-1-0.html

When you search from your web app do you search specific fields or just the default field? 当您从Web应用程序中搜索时,您是搜索特定字段还是仅搜索默认字段? When you type something into the admin console to debug searches, its easy to forget to tell it which field(s) you want to search on and if you don't tell it then only the default field is searched. 当您在管理控制台中键入内容以调试搜索时,很容易忘记告诉它您要搜索哪个字段,如果您没有告诉它,则只搜索默认字段。

https://stackoverflow.com/a/8082936/474597 has a better explaination, in which you need to include the search column name such as body_text:your_key_words https://stackoverflow.com/a/8082936/474597有一个更好的解释,你需要在其中包含搜索列名称,如body_text:your_key_words

尝试阅读调试搜索应用程序相关性问题 ,讨论解释和Solr分析工具。

为了调试发送给Solr的请求,我经常使用像tcpmonfiddler这样的http请求分析器。

将日志级别设置为FINEST,您将在日志文件中看到确切的查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM