[英]Solr - schema help (product attributes)
我想知道你們中是否有人可以幫助我在Solr中存儲產品屬性。 我遇到的問題是產品屬性因產品類別而異。 從我到目前為止所理解的,我必須列出我的架構中的字段。 屬性的數量相當大且不斷變化 - 你們有什么建議?
例如, 襯衫類別中的產品可能具有尺寸屬性,但房地產類別中的產品可能具有卧室屬性。
(我目前正計划不斷將MySQL數據導入Solr並主要使用Solr進行分面搜索)
您可以在solr中設置動態字段 。 在schema.xml中的<fields>
塊中,您可以配置動態字段定義,如下所示:
<fields>
...
<dynamicField name="*_t" type="text" indexed="true" stored="true" multiValued="false"/>
<dynamicField name="*_s" type="string" indexed="true" stored="true" multiValued="false"/>
<dynamicField name="*_sa" type="string" indexed="true" stored="true" multiValued="true" />
<dynamicField name="*_d" type="date" indexed="true" stored="true" multiValued="false"/>
<dynamicField name="*_f" type="sfloat" indexed="true" stored="true" multiValued="false"/>
<dynamicField name="*_i" type="sint" indexed="true" stored="true" multiValued="false"/>
<dynamicField name="*_ia" type="sint" indexed="true" stored="true" multiValued="true" />
</fields>
您想要的特定設置可能不同,但這是基本想法。
考慮上面的第一個dynamicField
定義。 它的含義是你可以動態添加任何以_t
結尾的字段,這些字段將被視為文本字段,將被索引和存儲,並將被視為單個值(而不是數組)。
您可以根據需要設置任意數量的動態字段名稱,並且您使用的名稱沒有任何重要性或約定。 只需為您可能擁有的每種數據類型設置一個dynamicField
定義。
然后就是這樣。 無需定義特定字段,只需使用您設置的后綴即可。 因此,例如,如果您使用上面的字段,您可以執行以下插入:
category_s = 'realty'
bedrooms_i = 4
或者你可以做一個插入:
category_s = 'shirts'
size_s = 'M'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.