Solr - schema help (product attributes)

I was wondering if any of you could help me with preserving product attributes in Solr. The problem is that product attributes vary by product category. From what I have understood so far, I would have to list the fields in my schema. The number of attributes is quite large and constantly changing - what do you guys suggest?

For example, a product in a shirt category may have a size attribute , but in a realty category there may be bedrooms .

(I am currently planning to constantly import MySQL data into Solr and use Solr for facsimile searches)

+3
source share
1 answer

You can configure dynamic fields in solr. In schema.xml in a block, <fields>you can configure dynamic field definitions as follows:

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

The specific settings you want may be different, but this is the main idea.

Consider the first definition dynamicFieldgiven above. This means that you can dynamically add any fields ending with _t, and these fields will be processed as text fields, will be indexed and saved and will be treated as a single value (unlike an array).

, , , . dynamicField , .

, . , , . , , , :

category_s = 'realty'
bedrooms_i = 4

:

category_s = 'shirts'
size_s = 'M'
+8

Source: https://habr.com/ru/post/1786257/


All Articles