简体   繁体   English

如何一次计算多个solr内核上的查询结果

[英]How to count the query result on multiple solr cores at once

Using multicore functionality of solr, we implemented multiple cores into one solr instance and each core having some specific information, like one core is stored Hotel's details along with city while another stored details of Events happening over the city and 3rd core stored details about restaurants in the city. 使用solr的多核功能,我们在一个solr实例中实现了多个核心,每个核心具有一些特定的信息,例如一个核心存储了酒店的详细信息以及城市,而另一个核心存储了发生在城市中的事件的详细信息,而第三个核心则存储了有关餐厅信息城市。 There are other parameters so that we created separate cores. 还有其他参数,因此我们创建了单独的核心。

My application is given search by keyword and I want to show list as: 我的应用程序通过关键字进行搜索,我希望将列表显示为:

  • hotel(numFound) 酒店(numFound)
  • Events(numFound) 活动(numFound)
  • Restaurants(numFound) 餐馆(numFound)

then user can drill down into his interested thing. 然后用户可以深入了解他感兴趣的事物。

How can we achieve this by querying to all cores and get the result as number of records found(numFound) for each core. 我们如何通过查询所有核心并以每个核心的找到的记录数(numFound)来获取结果。

Solr.xml: Solr.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<solr sharedLib="lib" persistent="true">
    <cores adminPath="/admin/cores" hostPort="${jetty.port:8983}" hostContext="${hostContext:solr}">
        <core default="true" instanceDir="hotelDetails" name="hotelDetails"/>
        <core default="false" instanceDir="Events" name="Events"/>
        <core default="false" instanceDir="Restaurants" name="Restaurants"/>
    </cores>
</solr>

You need to use Solr's Faceted search mechanism. 您需要使用Solr的Faceted搜索机制。 This link will guide you to get the faceted search. 该链接将指导您进行多方面的搜索。

There might be a lot of ways to achieve what you need. 可能有很多方法可以实现您所需要的。 Here's my solution 这是我的解决方案

  1. First create a custom field called " type ". 首先创建一个名为“ type ”的自定义字段。 Depending upon each core update it's relevant value (eg For hotelDetails type:hotel) in each document. 根据每个核心更新,它在每个文档中的相关值(例如,对于hotelDetails类型:hotel)。
  2. Do a distributed search using faceting. 使用构面进行分布式搜索 Add the following command in your search query and you'll get the result as expected. 在搜索查询中添加以下命令,您将获得预期的结果。

For distributed search add 对于分布式搜索,请添加

/select?collection=hotelDetails,Events,Restaurants / select?collection = hotel详细信息,活动,餐厅

For faceting 对于刻面

facet=true&facet.field=type facet = true&facet.field = type

Check with the following queries. 检查以下查询。 I hope both the query should work. 我希望两个查询都可以。

http://'localhost':8983/solr/hotelDetails/select?shards=localhost:8983/solr/hotelDetails,localhost:8983/solr/Events,localhost:8983/solr/Restaurants&q=some_query http://'localhost':8983 / solr / hotelDetails / select?shards = localhost:8983 / solr / hotelDetails,localhost:8983 / solr / Events,localhost:8983 / solr / Restaurants&q = some_query

and

http://'localhost':8983/solr/hotelDetails/select?collection=hotelDetails,Events,Restaurants&q=some_query http://'localhost':8983 / solr / hotelDetails / select?collection = hotelDetails,Events,Restaurants&q = some_query

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM