在Apache Solr实现设置默认搜索领域 [英] Set default search fields in Apache Solr

查看:1221
本文介绍了在Apache Solr实现设置默认搜索领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现 Apache Solr实现通过的搜索:// github上.COM / mausch / SolrNet相对=nofollow> SolrNet library.So到目前为止,我已经成功地在我的机器上运行的Solr的实例,并根据特定领域的一些疑问。
我的code做它看起来像这样

I am trying to Implement Apache Solr search through SolrNet library.So far I have managed to run an instance of Solr in my machine and make some queries based on specific fields. My code to do it looks like this

   var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Product>>();
   var results = solr.Query(new SolrQueryByField("id", "SP2514N"));

现在这一次工作得很好,但我想,以与出查询指定域,这样当我输入一个搜索关键字的Solr将放眼各个领域提供返回result.I找到了code键使它SolrNet库从这里

This one works fine now,But I would like to make queries with out specifying a field , So that when I enter a search key word solr will look in to the all fields available and return a result.I have Found the code to make it in SolrNet library from here

        var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Product>>();
        var results = solr.Query(new SolrQuery("SP2514N"));

但是,这从来没有工作过,当我往下钻至底部,我发现我需要设置Solr的情况下默认搜索字段,以便Solr的将搜索在没有其他选择的字段(这是我的理解是,我不肯定这一点)。
于是我去设置默认域Solr中,我把 solrconfig.xml中并编辑像这样

    <requestHandler name="/query" class="solr.SearchHandler" default="true">
     <lst name="defaults">
       <str name="echoParams">explicit</str>
       <str name="wt">json</str>
       <str name="indent">true</str>
       <str name="df">text</str>
       <str name="df">id</str>
     </lst>
  </requestHandler>

[刚添加&LT; STR NAME =DF&GT; ID&LT; / STR&GT; 这一领域作为额外]。但这也从来没有帮助而且我坚持,任何一个可以告诉我,我怎么能在Solr中正确设置默认搜索领域?还是我做任何事情别的错了吗?
我已经上传了我的文件Solrconfig这里

[just added <str name="df">id</str> this field as extra].But this too never helped And I am stuck ,Can any one tell me How I could set default search field in Solr correctly?Or am i doing any thing else wrong? I have Uploaded My Solrconfig file here

推荐答案

我不知道SolrNet库,而是使默认字段搜索您需要schema.xml中即来定义DefaultSearchField&LT ; defaultSearchField&GT;字段名&LT; / defaultSearchField方式&gt;

I do not know about SolrNet library, but to make a default field for search you need to define DefaultSearchField in schema.xml i.e. <defaultSearchField>FieldName</defaultSearchField>.

您可以找到这个文件@ <$c$c><SOLR_HOME>\\apache-solr-3.6.0\\example\\example-DIH\\solr\\testsyndrome\\conf\\schema.xml

You can find this file @ <SOLR_HOME>\apache-solr-3.6.0\example\example-DIH\solr\testsyndrome\conf\schema.xml

我希望这是你在找什么。

I hope that's what you are looking for.

这篇关于在Apache Solr实现设置默认搜索领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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