繁体   English   中英

Solr架构设计

[英]Solr Schema Design

我对Solr模式设计有一些疑问。 基本上,我正在为产品目录网站设置搜索引擎,并且我的表关系如下。

  • Product属于Merchant
  • Product属于Brand
  • Product具有并属于许多Categories
  • Category有许多Sub Categories
  • Sub Category有很多Types
  • Type有很多Sub Types

到目前为止,我的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"/>

所以我现在的问题是:

1)模式是否正确?

2)假设我需要找到Category XYZ产品。 我的高级程序员不喜欢按Category Name查询solr,而是不使用CategoryID 他建议存储CategoryID_CategoryName (1001_Category XYZ)并从Web前端发送ID。 (假设带空格的名称无法正常工作)。

因此,要查找产品,我应该对categories进行部分匹配,然后从字符串中识别类别ID,例如(fetch 1001 from 1001_Category XYZ)或者如果我保留“ categories名称”字段并为category_ids设置另一个字段怎么办? 对我来说,这似乎是一个更好的选择。

要么

是否有任何Solr多值字段类型可以将CategoryIDCategoryName一起存储?

让我知道您的想法,谢谢。

回答您的问题。

  1. 也许-这取决于您计划如何构造查询,要搜索的内容以及要在搜索结果中检索的内容。 在您的模式中,您正在存储和索引所有效率不高的内容。 索引要查询的内容,存储要检索/显示的内容。 如果您正在寻找优化,我将查看模式中使用的数据类型-尝试尽可能地保持原始类型不变。
  2. 按CategoryId查询-您的程序员是正确的,您想按类别ID查询。 您将ID和名称存储在单独字段中的方法也很准确。 假设基于Id的字段是整数/整数,则您不想将它们构造为字符串,而是将其构造为整数/整数。

暂无
暂无

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

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