在 Sunspot 上调试 Solr 搜索查询 [英] Debugging Solr search queries on Sunspot

查看:17
本文介绍了在 Sunspot 上调试 Solr 搜索查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Rails 上使用 Sunspot gem 时如何调试 Solr 搜索查询?我有一些查询返回了异常高的分数,我正在努力找出发生这种情况的原因.

How can I debug Solr search queries when using the Sunspot gem on Rails? I have some queries that are returning bizarrely high scores, and I'm trying to get to the bottom of why this is happening.

貌似没有任何调试信息暴露给Sunspot,所以我觉得我需要直接通过Solr调试.幸运的是,Solr 有一个方便的网络界面可供搜索,但出于某种原因,我在那里输入的任何查询都会返回 0 个结果.

It doesn't seem like any debugging information is exposed to Sunspot, so I think that I need to debug through Solr directly. Fortunately, Solr has a handy web interface to search from, but for some reason, any queries I enter there return with 0 results.

例如,当我在我的网络应用中搜索test"这个词时,它会返回大量的点击.当我在 Solr 管理界面上搜索同样的东西时,我得到了:

For example, when I search for the word "test" on my web app, it returns plenty of hits. When I search for the same thing on the Solr admin interface this is what I get:

<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> 

推荐答案

当您从 Web 应用程序搜索时,您是搜索特定字段还是仅搜索默认字段?当您在管理控制台中键入内容以调试搜索时,很容易忘记告诉它您要搜索哪个字段,如果您不告诉它,则只会搜索默认字段.

When you search from your web app do you search specific fields or just the default field? 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 有更好的解释,其中你需要包括搜索列名称,例如 body_text:your_key_words

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

这篇关于在 Sunspot 上调试 Solr 搜索查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆