[英]Solr Schema Design
I have some questions regarding the solr schema design. 我对Solr模式设计有一些疑问。 Basically I'm setting up a search engine for product catalogue website and my table relationships are as follows.
基本上,我正在为产品目录网站设置搜索引擎,并且我的表关系如下。
Product
Belongs to Merchant
Product
属于Merchant
Product
Belongs to Brand
Product
属于Brand
Product
has and belongs to many Categories
Product
具有并属于许多Categories
Category
has many Sub Categories
Category
有许多Sub Categories
Sub Category
has many Types
Sub Category
有很多Types
Type
has many Sub Types
Type
有很多Sub Types
So far my Schema.xml is looks like this. 到目前为止,我的Schema.xml看起来像这样。
<field name="product_id" type="string" indexed="true" stored="true" required="true" />
<field name="name" type="string" indexed="true" stored="true"/>
<field name="merchant" type="string" indexed="true" stored="true"/>
<field name="merchant_id" type="string" indexed="true" stored="true"/>
<field name="brand" type="string" indexed="true" stored="true"/>
<field name="brand_id" type="string" indexed="true" stored="true"/>
<field name="categories" type="string" multiValued="true" indexed="true" stored="true"/>
<field name="sub_categories" type="string" multiValued="true" indexed="true" stored="true"/>
<field name="types" type="string" multiValued="true" indexed="true" stored="true"/>
<field name="sub_types" type="string" multiValued="true" indexed="true" stored="true"/>
<field name="price" type="float" indexed="true" stored="true"/>
<field name="description" type="text" indexed="true" stored="true"/>
<field name="image" type="text" indexed="true" stored="true"/>
<field name="text" type="text" indexed="true" stored="false" multiValued="true"/>
<uniqueKey>product_id</uniqueKey>
<defaultSearchField>text</defaultSearchField>
<solrQueryParser defaultOperator="OR"/>
<copyField source="name" dest="text"/>
<copyField source="merchant" dest="text"/>
<copyField source="brand" dest="text"/>
<copyField source="categories" dest="text"/>
<copyField source="sub_categories" dest="text"/>
<copyField source="types" dest="text"/>
<copyField source="sub_types" dest="text"/>
So my Questions now: 所以我现在的问题是:
1) Is the Schema correct? 1)模式是否正确?
2) Let's assume I need to find products for Category XYZ
. 2)假设我需要找到
Category XYZ
产品。 My Senior programer doesn't like querying the solr by Category Name
, instead he wan't to use CategoryID
. 我的高级程序员不喜欢按
Category Name
查询solr,而是不使用CategoryID
。 He is suggesting to store CategoryID_CategoryName (1001_Category XYZ)
and from web front he is sending ID. 他建议存储
CategoryID_CategoryName (1001_Category XYZ)
并从Web前端发送ID。 (Assuming that Names with white spaces doesn't work properly). (假设带空格的名称无法正常工作)。
So to find the products I should then do a partial match of categories
and identify the category id from the string ie (fetch 1001 from 1001_Category XYZ)
or What if I keep the Names on categories
field and setup another field for category_ids
? 因此,要查找产品,我应该对
categories
进行部分匹配,然后从字符串中识别类别ID,例如(fetch 1001 from 1001_Category XYZ)
或者如果我保留“ categories
名称”字段并为category_ids
设置另一个字段怎么办? that's seems a better option for me. 对我来说,这似乎是一个更好的选择。
or 要么
is there any Solr multi valued field type to store CategoryID
and CategoryName
together? 是否有任何Solr多值字段类型可以将
CategoryID
和CategoryName
一起存储?
Let me know your thoughts, thanks. 让我知道您的想法,谢谢。
Answers to your questions. 回答您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.