Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何查询Solr shard_Solr_Sharding - Fatal编程技术网

如何查询Solr shard

如何查询Solr shard,solr,sharding,Solr,Sharding,我跟着在索尔建立了shard。根据本主题,在两台本地服务器上测试索引切分,我能够查询切分并得到以下结果:port1/solr/select?shards=somehost:port1/solr,somehost:port2/solr&indent=true&q=helloworld 在该页面中还提到,与其要求用户显式地包含shards参数,通常更倾向于在solrconfig.xml的RequestHandler部分将该参数配置为默认值。 因此,我在port1上运行的solr实例的solrcon

我跟着在索尔建立了shard。根据本主题,在两台本地服务器上测试索引切分,我能够查询切分并得到以下结果:port1/solr/select?shards=somehost:port1/solr,somehost:port2/solr&indent=true&q=helloworld

在该页面中还提到,与其要求用户显式地包含shards参数,通常更倾向于在solrconfig.xml的RequestHandler部分将该参数配置为默认值。 因此,我在port1上运行的solr实例的solrconfig.xml中进行了更改

    <requestHandler name="/select" class="solr.SearchHandler">

      <lst name="defaults">
       <str name="echoParams">explicit</str>
       <int name="rows">10</int>
        <str name="df">text</str>
       </lst>
    <lst name="shards.info">
     <lst name="localhost:port2/solr">
     <long name="numFound">1333</long>
    <float name="maxScore">1.0</float>
    <str name="shardAddress">http://localhost:port2/solr</str>
   <long name="time">686</long>
   </lst>
  <lst name="localhost:port1/solr">
   <long name="numFound">342</long>
   <float name="maxScore">1.0</float>
   <str name="shardAddress">http://localhost:port1/solr</str>
   <long name="time">602</long>
  </lst>
  </lst>
现在,我尝试访问某个主机:port1/solr/collection1/select?q=helloworld&wt=json&indent=true
但我没有得到想要的回应。请告诉我这里缺少什么?

您不能将响应中的内容复制到配置文件中,这两种格式完全不同。这里提到的事实是,默认值部分中的每个条目都会添加到查询字符串中,除非已经提供了它们-如果您想强制某个无法重写的值,还可以使用一些选项

<requestHandler name="/selectdistributed" class="solr.SearchHandler">
    <lst name="defaults">
        [...]
        <str name="shards">somehost:port1/solr,somehost:port2/solr</str>
    </lst>
</requestHandler>

。。你应该做你想做的。这将把shards=somehost:port1/solr,somehost:port2/solr添加到通过该处理程序的所有请求的查询字符串中。

如果我按照您的建议这样做,那么查询将进入无限循环,这在apache站点中提到。不要将shards参数添加到标准requestHandler中;否则,搜索查询可能会进入无限循环。相反,定义一个使用shards参数的新requestHandler,并将分布式搜索请求传递给该处理程序。我也会将其添加到定义中。只是解释一下——您在配置文件中添加的内容只是分布式搜索返回的内容的一个示例,而不是如何配置它。