同一Solr核心中的多个索引..? [英] Multiple Indexes in same Solr Core..?
问题描述
我正在使用Apache Solr ..我有以下场景..:
I am using Apache Solr..I have the following Scenario.. :
我的PostGreSQL数据库中有两个表。一个是 汽车 。其他是经销商
I have Two table in my PostGreSQL database. One is "Cars". Other is "Dealers"
现在我有 汽车的数据配置文件 如下所示:
Now i have a data-config file for Cars like the following :
<document name="offerings">
<entity name="jc_offerings" query="select * from jc_offerings" >
<field column="id" name="id" />
<field column="name" name="name" />
<field column="display_name" name="display_name" />
<field column="extra" name="extra" />
</entity>
</document>
我有一个类似的数据 - 经销商的
I have a similar data--config.xml for "Dealers". It has the same fields as Cars : name, extra etc
现在在我的Schema.xml中,我定义了以下字段:
Now in my Schema.xml , i have defined the following fields :
<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"/>
现在我想搜索:其中名称是Maruti..那么Solr将如何知道是否搜索:::汽车领域:名称或经销商字段名称.. ??
Now i want to search like : "where name is Maruti"..So how will Solr know Whether to Search ::: Cars Field : name OR Dealer Field "name"..??
我已阅读以下链接: http://wiki.apache.org/solr/MultipleIndexes
但是我无法理解它是如何起作用的。??
But i am not able to understand how is works..??
阅读完链接后:我在我的汽车和经销商 * data-config.xml * ..类似于:
After reading that link : I made another field in My Cars and Dealers *data-config.xml* .. Something like :
<field name="type" value="car" /> : in Cars date-config.xml
和
<field name="type" value="dealer" /> : in Cars date-config.xml
然后在Schema.xml中我创建了一个新字段:
And then in Schema.xml i created a new field :
<field name="type" type="string" indexed="true" stored="true" />
然后我查询类似:
localhost:8983 / solr / select?q = name:Maruti& fq = type:dealer
但它工作.. !!
那我该怎么办.. ??
So what should i do..??
推荐答案
如果汽车和经销商的字段相同,您可以使用一个索引,其对象定义如下:
if the fields are the same for both cars and dealers, you could use one index with an object defined like so:
<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个索引)和如果你想要一个经销商或汽车(我使用相同的系统过滤掉只有轻微的semanthical差异的相似类型的物品),你将使用类型字段来理清
this will work for both cars and dealers (so you don't need to have 2 indexes) and you'll use the "type" field to sort out if you want a "dealer" or a "car" (i'm using the same system to filter out similar types of objects with only a minor "semanthical" difference)
您还需要将stored =true添加到要检索的字段中,否则您将只能使用它们进行搜索(因此该索引= 真实)
also you'll need to add stored="true" to the fields you want to retrieve, or you'll be only able to use them for searching (hence that index="true")
这篇关于同一Solr核心中的多个索引..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!