簡體   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