Solr In Action

2019-03-27 01:18|来源: 网路

1.  solr.xml – Defines one or more cores per Solr server 
2.  solrconfig.xml  – Defines the main settings for a specific Solr core 

3.  schema.xml  – Defines the structure of your index including fields and field types 



<solr persistent="true"> #A 
  <logging enabled="true"> 
    <watcher size="100" threshold="INFO" /> 
  </logging>  
   
  <cores adminPath="/admin/cores"  #B  
         defaultCoreName="collection1"   
         host="${host:}" hostPort="${jetty.port:}" 
	 hostContext="${hostContext:}"   
         zkClientTimeout="${zkClientTimeout:15000}">  
    <core name="collection1" instanceDir="collection1" /> #C 
  </cores>  
</solr>
#A persistent attribute controls whether changes made from the core admin API are persisted to this file  
#B define one or more cores under the <cores> element 
#C the collection1 core configuration and index files are in the collection1 directory under solr home 

The initial configuration only has a single core named "collection1", but in general there can be many cores defined in solr.xml.  For each core, Solr locates the solrconfig.xml   file, under $SOLR_HOME/$instanceDir /conf/solrconfig.xml, where  $ instanceDir   is the directory for a  specific core as specified in  solr.xml.  Solr uses the solrconfig.xml   file to initialize the core

solrconfig.xml 
<config>  
  <luceneMatchVersion>LUCENE_40</luceneMatchVersion>      #A  
  <lib dir="../../../contrib/extraction/lib" regex=".*\.jar" /> #B 
  <dataDir>${solr.data.dir:}</dataDir >                    #C  
  <directoryFactory name="DirectoryFactory" class="..."/> #C  
  <indexConfig> ... </indexConfig>                        #C  
  <jmx />  #D 
  <updateHandler class="solr.DirectUpdateHandler2"> #E 
    <updateLog> ... </updateLog>                    #E 
    <autoCommit> ... </autoCommit>                  #E  
  </updateHandler>                                  #E 
  <query>                               
    <filterCache ... />              #F  
    <queryResultCache ... />         #F  
    <documen tCache ... />            #F 
    <listener event="newSearcher" class="solr.QuerySenderListener">   #G 
      <arr name="queries"> ... </arr>                                 #G
    </listener>                                                       #G 
    <list ener event="firstSearcher" class="solr.QuerySenderListener"> #G  
      <arr name="queries"> ... </arr>                                 #G 
    </listener>                                                       #G 
  </query>  
  <requestDispatcher handleSelect="false" >                           #H  
    <requestParsers ... /> 
    <httpCaching never304="true" /> 
  </requestDispatcher>  
  <requestHandler name="/select" class="solr.SearchHandler">          #I  
    <lst name="defaults"> ... </lst>                                   #I 
    <lst name="appends"> ... </lst>                                   #I 
    <lst name="invariants"> ... </lst>                                #I 
    <arr name="components"> ... </arr>                                #I 
    <arr name="last -com ponents"> ... </arr>                           #I 
  </requestHandler>                                                   #I  
  <searchComponent name="spellcheck"                                  #J  
      class="solr.SpellCheckComponent"> ... </searchComponent > 
  <updateRequestProcessorChain name="langid"> ...                     #K  
      </updateRequestProcessorChain>  
  <queryResponseWriter name="json"                  #L 
      class="solr.JSONResponseWriter"> ... </queryResponseWriter> 
  <valueSourceParser name="myfunc" ... />   #M 
  <transformer name="db"    #N  
      class="com.mycompany.LoadFromDatabaseTransformer">  
      ... </transformer>  
</config> 

#A Activates version -dependent features in Lucene, see 4.2.1  
#B Lib directives indicate where Solr can find JAR files for extensions , see 4.2.1  
#C Index management settings covered in chapter 5 
#D Enable JMX instrumentation of Solr MBeans, see 4.2.1  
#E Update handler for indexing documents, see chapter 5  
#F Cache management settings , see section 4.4  
#G Register event handlers for searcher events, e.g. queries to execute to warm new searchers , 
section 4.3 
#H Unified request dispatcher, section 4.2  
#I Request handler to process queries using a chain of search components, 4.2.4 
#J Example search component for doing spell correction on queries 
#K Extend indexing behavior using update request processors, such as language detection 
#L Format the response as JSON  
#M Declare a custom function for boosting, ranking or sorting documents  

#N Transforms result documents


Listing 4.4   HTTP GET request to query the example Solr server 
http://localhost:8983/solr/collection1/select ?    #A 
q=iPod&                                          #B 
fq=manu%3ABelkin&                                #C 
sort=price+asc&                                   #D 
fl=name%2Cprice%2Cfeatures%2Cscore&               #E 
df=text&                                         #F 
wt=xml&                                          #G 
start=0&rows=10                                  #H 
#A Invokes the "select" request handler for the "collection1" core  
#B Main query component looking for documents containing "iPod" 
#C Filter documents that have manu field equal to "Belkin" 
#D Sort results by price in ascending order (smallest to largest)  
#E Return the name, price, features, and score fields in results 
#F Default search field is "text"  
#G Return results in XML format 
#H Start at page 0 and return up to 10 results



Starting at the top-left   of figure 4.4: 
1.  A client application sends an HTTP GET request to http://localhost:8983/solr/collection1/select?q=... Query parameters are passed along in the query  string of the GET request.  
2.  Jetty accepts the request and routes it to Solr's unified request dispatcher using the /solr  context in the request path.  In technical terms, the unified request dispatcher 
is a Java servlet f ilter mapped to /*  for the solr Web  application, see org.apache.solr.servlet.SolrDispatchFilter. 

3.  Solr's request dispatcher uses the "collection1" part of the request path to determine the core name. Next, the dispatcher locates the /select  request handler registered in solrconfig.xml for the   collection1  core. 
4.  The /select   request handler processes the request using a pipeline of search comp onents (covered in section 4.2.4  below).  
5.  After the request is processed, results are formatted by a response writer component and returned to the client application , by default the /select   handler returns results as XML. Response writers are covered in section 4.5.

The main purpose of the request dispatcher is to locate the correct core to handle the request, such as  collection1, and then route the request to   the appropriate request handler registered in the core, in this case  /select .  In practice , the default configuration for the request dispatcher is sufficient  for most applications .  On the other hand, it is common to define a custom search req uest handler or to customize one of the existing handler s,   such as /select .  Let's dig into how the /select   handler works to gain a better understanding of how to customize a request handler . 

Listing 4.5 Definition of /select request handler from solrconfig.xml  
<requestHandler name="/select"               #A 
                class="solr.SearchHandler"> #B 
  <lst name="defaults">                     #C 
    <str name="echoParams">explicit</str>   
    <int name="rows">10</int>                 #D 
    <str name="df">text</str>  
  </lst> 
</requestHandler> 
#A  A specific type of request handler designed to process queries 
#B Java class that implements the request handler  
#C  List of defau lt parameters  (name/value pairs)  
#D  Sets the default page size to 10

1.  request parameter decoration   using: 
a.   defaults: set default parameters on the request if they are not explic itly provided by the client  
b.   invariants : set parameters to static values, which override values provided by the client  
c.   appends :  additional  parameters to be combined with the parameters provided by the client 
2.  first-components : optional chain of search components that are applied first to perform pre -processing tasks 
3.  components : primary chain of search components; must at least include the query component  
4.  last-components: optional chain of search components that are applied last to perform post-processing tasks   

<requestHandler name="/browse" class="solr.SearchHandler"> #A 
      <lst name="defaults">                            #B 
       <str name="echoParams">explicit</str> 
       <str name="wt">velocity</str>                  #C 
       <str name="v.template">browse</str>            #C 
       <str name="v.layout">layout</str>              #C 
       <str name="title">Solritas</str>               #C 
 
       <str name="defType">edismax</str>              # D 
 
       <str name="qf">text^0.5 features^1.0 ...</str> #E 
 
       <str name="mlt.qf">text^0.5 features^1.0 ...</str> #F  
        
       <str name="facet">on</str>  #G  
      ...  
       <str name="hl">on</str>   #H  
       ...  
       <str name="spellcheck">on</str> #I 
       ... 
      </lst> 
      <arr name="last -components">   
       <str>spellcheck</str>    #J 
      </arr> 
  </requestHandler> 
#A A SearchHandler invokes query processing pipeline 
#B default list of query parameters 
#C VelocityResponseWriter settings 
#D Use the extended dismax query parser  
#E Query settings 
#F Enable the MoreLikeThis component  
#G Enable the Facet component 
#H Enable the Highlight component  
#I Enable spell checking 
#J Invoke the spell checking component as the last step in the pipelin e 



转自:http://blog.csdn.net/li385805776/article/details/11365199

相关问答

更多
  • 你试过吗? 卷曲“http://'localhost':8080 / solr / admin / cores?action = SWAP&core = core1&other = core0” 从壳? Did you try with curl "http://'localhost':8080/solr/admin/cores?action=SWAP&core=core1&other=core0" from shell?
  • 您仍然必须将配置集上传到zookeeper。 您可以在cloud-> tree-> configs下的admin UI中找到zookeeper上的配置集列表。 这些集合在cloud-> tree-> collections下。 如果单击某个集合,则可以找到与其关联的配置集:({“configName”:“MyConfig”}) 您可以使用solr主机上的zkcli.sh命令将配置集上传到zookeeper: cd /opt/solr/server/scripts/cloud-scripts ./zkcli. ...
  • 看起来您正在使用SolrCloud示例。 在这种情况下,配置被加载到Zookeeper中。 因此,实时版本不在文件系统上,因为它与非云例子相同。 您可以通过管理界面查看,而不是。 如果您只想查看引导配置,它位于server / solr / configsets /中,具体配置取决于您在创建示例时选择的内容。 It looks like you are using SolrCloud example. In which case, the configuration is loaded into Zooke ...
  • 我联系了Adobe,并且(令人惊讶地)得到了一些帮助。 他们说ColdFusion正式不支持非ColdFusion Solr服务器。 最后,我们刚刚安装了包含ColdFusion的Solr服务器(当然,通过重新安装ColdFusion)。 另外,他们说ColdFusion附带的Solr服务器是3.4.x版本。 ColdFusion独立Solr服务器版本相同。 我们可能已经安装了CF独立服务器,但为了简单起见选择了本地服务器(经过我们已经遇到的所有麻烦)。 作为旁注,可以使用与ColdFusion不同的Sol ...
  • 我可以在使用您的架构和创建表语句后重现您的错误。 在尝试创建核心几次崩溃之后,服务器最终会发出错误,可能是因为它处于不一致状态。 如果您在架构中使用以下内容,我想一切都会好的。 我需要知道确切的版本才能100%肯定。 为了避免将来出现问题,我建议你: 在demos文件夹中查找“wiki”演示。 将其用作模板。 更改脚本的核心名称,更改架构,更改solrc ...
  • 不,据我所知,目前这是不可能的(没有在服务器上创建文件,然后从文件创建核心)。 如果需要这种功能,您可能希望为架构使用更多无架构的结构,您可以在其中定义一组映射到字段的不同默认设置的字段前/后缀,然后使用通配符名称来避免定义架构中的每个字段。 基于Lucene的真正模式替代方案也可以是弹性搜索。 No, as far as I know, this is not possible at the moment (without creating the files on the server, then cr ...
  • 当你正在进行模糊搜索(或通配符搜索等 - 任何一个词的搜索都可以在索引端评估为多个标记)时,分析链不会被应用(除了多词条意识的过滤器,通常是LowercaseFilter,仅此而已)。 解决方案通常是在标准化途中使用标记,可能是通过针对您正在搜索的数据编写的过滤器。 When you're doing a fuzzy search (or a wildcard search, etc. - any search for one term could evaluate to multiple tokens o ...
  • 您正在使用错误的API。 UpdateRequest用于对索引数据执行操作(添加/删除文档等),而不用于管理集合的设置方式,例如创建分片,您需要使用此 You are using the wrong api. The UpdateRequest is for performing actions on the index data (adding/deleting docs etc), not for managing how the collection is set up, for creating a ...
  • 这个脚本可以工作: param ($prefix = $(throw "-prefix is required")) $client = (New-Object System.Net.WebClient) [xml]$coresXML = $client.DownloadString("http://localhost:8983/solr/admin/cores") $cores = $coresXML.response.lst[2].lst | % {$_.name} $success = 0 $err ...
  • 他们今天刚刚宣布您现在可以将群集自定义应用于正在运行的群集 。 请参阅Solr群集自定义页面。 仍不建议手动在正在运行的集群上安装内容(而不是使用集群自定义脚本)。 首先,当需要关闭一个节点进行维护时,新节点将在没有安装自定义软件的情况下重新启动。 其次,群集自定义脚本与Azure通信,支持在打开支持案例时对群集所做的更改。 They just announced today that you can now apply cluster customizations to a running cluster ...