dpnw86361 2011-12-01 11:24
浏览 156
已采纳

更新Solr配置以搜索所有字段

Can anyone advise me on how to search Solr on all fields?

This is my current requestHandler called "search" and using solr.SearchHandler.

<requestHandler name="search" class="solr.SearchHandler" default="true">
  <!-- default values for query parameters can be specified, these
         will be overridden by parameters in the request
    -->
   <lst name="defaults">
    <str name="echoParams">explicit</str>
    <int name="rows">10</int>
   </lst>
</requestHandler>

It appears that I can search on all textual fields, however I need to search on a field called 's_number' and this is an integer.

Do I need to use DisMax to allow for searching on all fields?

Also, do I need to adjust the defaultSearchField in schema.xml? It is currently:

<defaultSearchField>text</defaultSearchField>
  • 写回答

2条回答 默认 最新

  • dongzichan2886 2011-12-01 17:24
    关注

    To search on non-textual fields you probably don't have to edit the config files. You just need to add the parameter correctly to your solr query.

    The basic idea is you can use key/value pairs to search on non-textual fields. See http://wiki.apache.org/solr/SolrQuerySyntax.

    To search on just s_number, you'd set up your query to the solr server like this:

    q=s_number:123
    

    This will return only results where s_number is 123, as expected -- and it does it as a regular search, not a post-search filter. I don't know what php solr library you're using, so I can't give you the exact code for how to set up this query parameter in your code. If you tell me what library you are using and/or post the source code that actually does the search, I might be able to give you more precise details.

    But talking directly to your solr server, the query would look something like this:

    http://your-solr-server:8983/solr/select/?q=s_number%3A123
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 luckysheet
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱