Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.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 Core中有多个索引。。?_Solr_Indexing - Fatal编程技术网

同一Solr Core中有多个索引。。?

同一Solr Core中有多个索引。。?,solr,indexing,Solr,Indexing,我正在使用Apache Solr..我有以下场景..: 我的PostGreSQL数据库中有两个表。一个是“汽车”。另一个是“经销商” 现在我有了一个汽车的数据配置文件,如下所示: 我有一个类似的数据--config.xml用于“经销商”。它与汽车具有相同的字段:名称、额外等 现在,在我的Schema.xml中,我定义了以下字段: <fields> <field name="id" type="string" indexed="true" /> <

我正在使用Apache Solr..我有以下场景..:

我的PostGreSQL数据库中有两个表。一个是“汽车”。另一个是“经销商

现在我有了一个汽车的数据配置文件,如下所示:


我有一个类似的数据--config.xml用于“经销商”。它与汽车具有相同的字段:名称、额外等

现在,在我的Schema.xml中,我定义了以下字段:

<fields>
  <field name="id" type="string"   indexed="true" />
  <field name="name" type="name"  indexed="true" />
  <field name="extra" type="extra"  indexed="true"  /> 

  <field name="CarsText" type="text_general" indexed="true" 
    stored="true" multiValued="true"/>
</fields>

<uniqueKey>id</uniqueKey>
<defaultSearchField>CarsText</defaultSearchField>
<copyField source="name" dest="CarsText"/>
<copyField source="extra" dest="CarsText"/>

身份证件
卡斯特克斯
现在我想搜索“where name is Maruti”。那么Solr如何知道是搜索:::Cars字段:name还是经销商字段“name”

我已阅读以下链接:

但我无法理解is是如何工作的

在阅读该链接后:我在我的汽车经销商*data config.xml*中创建了另一个字段。。比如:

<field name="type" value="car" />  : in Cars date-config.xml
:车内日期-config.xml

:车内日期-config.xml
然后在Schema.xml中,我创建了一个新字段:

<field name="type" type="string"   indexed="true" stored="true" />  

然后我问了一些类似的问题:

localhost:8983/solr/select?q=name:Maruti&fq=type:dealer

但它的力量不起作用


那么我该怎么办呢?..

如果汽车和经销商的字段都相同,您可以使用一个索引和一个定义如下的对象:

<fields>
  <field name="id" type="string"   indexed="true" stored="true"/>
  <field name="name" type="name"  indexed="true" stored="true" />
  <field name="extra" type="extra"  indexed="true" stored="true" /> 
  <field name="description_text" type="text_general" indexed="true" stored="true" multiValued="true"/>
  <field name="type" type="string" indexed="true" stored="true" />
</fields>

这将适用于汽车和经销商(因此不需要有2个索引),并且您将使用“类型”字段来分类您想要的是“经销商”还是“汽车”(我使用相同的系统来过滤类似类型的对象,只有一个很小的“语义”差异)


此外,您还需要将stored=“true”添加到要检索的字段中,否则您只能使用它们进行搜索(因此index=“true”)

向type字段添加默认值将确保将type值设置为
cars | dealer

您必须单独为源编制索引。然后使用复制字段,您可以轻松地在
汽车|经销商
上进行筛选


这似乎有点棘手,在上面提到的多索引链接中没有得到很好的解释。

你仔细阅读我的问题了吗?....我想我已经这样做了..但事实是:它不起作用..当我查询类型时,结果中没有任何结果..我应该怎么做?我仔细阅读了你的问题,即使不是完美的英语。据我所知,你仍然有多个索引。您应该按照我的示例将所有内容合并到一个索引中。字段“type”也有两个默认值,分为两个索引。此外,当您查询“Maruti”而不查询其他内容时,输出是什么?在您的示例中:您提到了“类型”字段..现在如果您写“fq=type:Samuele.”。出现了什么......您需要在某个地方定义类型..例如“汽车”或“经销商”…SOLR应该能够知道有多少类型可用..您是如何做到的..我只是将该字段视为任何其他字段,并在索引时填充它。你有一个博士后数据库,对吗?所以你知道你是在拉“汽车”还是“经销商”的东西。您可以从那里轻松地将值传递给solr(或者像我那样编写插件,但我需要管理更大更复杂的数据)@Samuele Mattiuzzo建议您在solr模式中添加一个类型字段。将“cars”中的行添加到索引时,使用“car”类型插入。将“经销商”中的行添加到索引时,请使用“经销商”类型插入。然后要查询其中一个,您需要执行以下操作?q=*:*&fq=type:car或?q=*:*&fq=type:dealer。希望这有帮助。
<field name="type" type="string"   indexed="true" stored="true" />  
<fields>
  <field name="id" type="string"   indexed="true" stored="true"/>
  <field name="name" type="name"  indexed="true" stored="true" />
  <field name="extra" type="extra"  indexed="true" stored="true" /> 
  <field name="description_text" type="text_general" indexed="true" stored="true" multiValued="true"/>
  <field name="type" type="string" indexed="true" stored="true" />
</fields>