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

查看:109
本文介绍了在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拥有一个方便的Web界面供您搜索,但是由于某种原因,我在那里输入的任何查询都返回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.

例如,当我在Web应用程序中搜索测试"一词时,它会返回大量匹配.当我在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> 

推荐答案

从网络应用中搜索时,您是搜索特定字段还是仅搜索默认字段?当您在管理控制台中键入内容以调试搜索时,很容易忘记告诉您要搜索的字段,如果您不输入,则仅搜索默认字段.

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天全站免登陆